diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/backup.c | 165 | ||||
-rw-r--r-- | src/builtin.c | 10 | ||||
-rw-r--r-- | src/config.c | 26 | ||||
-rw-r--r-- | src/dictionary.c | 11 | ||||
-rw-r--r-- | src/directive.c | 8 | ||||
-rw-r--r-- | src/diskio.c | 6 | ||||
-rw-r--r-- | src/exec.c | 2 | ||||
-rw-r--r-- | src/gpg.c | 7 | ||||
-rw-r--r-- | src/job.c | 2 | ||||
-rw-r--r-- | src/lock.c | 12 | ||||
-rw-r--r-- | src/mail.c | 14 | ||||
-rw-r--r-- | src/net.c | 4 | ||||
-rw-r--r-- | src/process.c | 4 | ||||
-rw-r--r-- | src/sql.c | 4 | ||||
-rw-r--r-- | src/timer.c | 5 | ||||
-rw-r--r-- | src/triplet.c | 17 | ||||
-rw-r--r-- | src/txtacc.c | 16 | ||||
-rw-r--r-- | src/verify.c | 4 | ||||
-rw-r--r-- | src/wydawca.c | 8 | ||||
-rw-r--r-- | src/wydawca.h | 20 |
21 files changed, 268 insertions, 82 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8139849..3b524ba 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,71 +1,72 @@ # This file is part of Wydawca # Copyright (C) 2007, 2009, 2010 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, 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/>. sbin_PROGRAMS=wydawca wydawca_SOURCES=\ + backup.c\ builtin.c\ builtin.h\ cmdline.h\ config.c\ dictionary.c\ directive.c\ diskio.c\ exec.c\ gpg.c\ interval.c\ job.c\ lock.c\ meta.c\ net.c\ pidfile.c\ process.c\ pushd.c\ sql.c\ sql.h\ tcpwrap.c\ triplet.c\ userprivs.c\ verify.c\ wydawca.c\ wydawca.h\ mail.h\ mail.c\ vtab.c\ null.c\ timer.c\ txtacc.c\ report.c BUILT_SOURCES=cmdline.h EXTRA_DIST=cmdline.opt pp-setup update-2.0.awk SUFFIXES=.opt .c .h .opt.h: $(AM_V_GEN)m4 -s $(top_srcdir)/@GRECS_SUBDIR@/build-aux/getopt.m4 $< > $@ incdir=$(pkgdatadir)/$(VERSION)/include inc_DATA = $(PP_SETUP_FILE) -LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ -INCLUDES = -I$(top_srcdir)/grecs/src/ -I$(top_srcdir)/gnu -I../gnu @MAILUTILS_INCLUDES@ +LDADD=../grecs/src/libgrecs.a @SQLLIB@ @GPGMELIB@ @MAILUTILS_LIBS@ +INCLUDES = -I$(top_srcdir)/grecs/src/ @MAILUTILS_INCLUDES@ AM_CPPFLAGS= \ -DSYSCONFDIR=\"$(sysconfdir)\"\ -DLOCALSTATEDIR=\"$(localstatedir)\"\ -DDEFAULT_VERSION_INCLUDE_DIR=\"$(incdir)\"\ -DDEFAULT_INCLUDE_DIR=\"$(pkgdatadir)/include\"\ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" diff --git a/src/backup.c b/src/backup.c new file mode 100644 index 0000000..312375d --- /dev/null +++ b/src/backup.c @@ -0,0 +1,165 @@ +/* wydawca - automatic release submission daemon + Copyright (C) 2011 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" + +char const *simple_backup_suffix = "~"; + +static const char * +split_filename (char const *file, char **pdir) +{ + const char *p = strrchr (file, '/'); + + if (!p) + { + *pdir = grecs_strdup ("."); + p = file; + } + else + { + size_t len = p - file; + char *dir = grecs_malloc (len + 1); + memcpy (dir, file, len); + dir[len] = 0; + *pdir = dir; + p++; + } + return p; +} + +#define MINSUFSIZE 8 +#define ISDIGIT(c) ('0' <= (c) && (c) <= '9') + +static char * +get_backup_suffix (char const *file, enum backup_type type) +{ + char *dirname; + const char *basename; + size_t baselen; + DIR *dir; + struct dirent *ent; + char *lastsuf = NULL; + size_t lastsuflen = 0; + size_t lastsufsize = 0; + int carry; + char *newsuf; + char *q; + + if (type == simple_backups) + return grecs_strdup (simple_backup_suffix); + + basename = split_filename (file, &dirname); + baselen = strlen (basename); + dir = opendir (dirname); + if (!dir) + { + int ec = errno; + free (dirname); + errno = ec; + return NULL; + } + + while ((ent = readdir (dir))) + { + size_t len = strlen (ent->d_name); + const char *p; + size_t suflen; + + if (len < baselen + 4 || memcmp (ent->d_name, basename, baselen)) + continue; + p = ent->d_name + baselen; + suflen = len - baselen; + if (p[0] == '.' && p[1] == '~' && p[suflen-1] == '~' && + (suflen > lastsuflen + || (suflen == lastsuflen && + memcmp (p, lastsuf, lastsuflen) > 0))) + { + carry = 1; + for (q = (char*) p + suflen - 2; q > p + 1 && ISDIGIT (*q); q--) + if (*q != '9') + carry = 0; + q++; + if (!ISDIGIT (*q)) + continue; + + if (suflen > lastsufsize) + { + lastsufsize = suflen; + if (!lastsuf) + { + if (lastsufsize < MINSUFSIZE) + lastsufsize = MINSUFSIZE; + lastsuf = grecs_malloc (lastsufsize); + } + else + lastsuf = grecs_realloc (lastsuf, lastsufsize); + } + memcpy (lastsuf, p, suflen); + lastsuflen = suflen; + } + } + closedir (dir); + free (dirname); + + if (lastsuf) + { + size_t newsuflen; + + newsuflen = lastsuflen + carry; + newsuf = grecs_malloc (newsuflen + 1); + newsuf[0] = '.'; + newsuf[1] = '~'; + newsuf[2] = '0'; + memcpy (newsuf + 2 + carry, lastsuf + 2, lastsuflen - 3); + newsuf[newsuflen-1] = '~'; + newsuf[newsuflen] = 0; + + for (q = newsuf + newsuflen - 2; *q == '9'; q--) + *q = '0'; + ++*q; + free (lastsuf); + } + else if (type == numbered_existing_backups) + newsuf = grecs_strdup (simple_backup_suffix); + else + newsuf = grecs_strdup (".~1~"); + return newsuf; +} + +char * +find_backup_file_name (char const *file, enum backup_type type) +{ + size_t flen; + char *suffix; + char *newname; + + if (type == no_backups) + { + errno = 0; + return NULL; + } + + suffix = get_backup_suffix (file, type); + if (!suffix) + return NULL; + flen = strlen (file); + newname = grecs_malloc (flen + strlen (suffix) + 1); + memcpy (newname, file, flen); + strcpy (newname + flen, suffix); + free (suffix); + /* FIXME: Check newname length */ + return newname; +} diff --git a/src/builtin.c b/src/builtin.c index 9d1063c..8a07eab 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -1,68 +1,70 @@ /* wydawca - automatic release submission daemon Copyright (C) 2009, 2010 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" #include "builtin.h" -#include "fnmatch.h" -#include "regex.h" + +#ifndef FNM_CASEFOLD +# define FNM_CASEFOLD 0 +#endif int builtin_init (struct dictionary *dict) { return 0; } int builtin_done (struct dictionary *dict) { return 0; } void * builtin_open (struct dictionary *dict) { return dict; } #define CMP_EXACT 0 #define CMP_FNMATCH 1 #define CMP_REGEX 2 #define RF_ICASE 0x1 #define RF_BASIC 0x2 #define STRMATCH(s, p, len) \ (len == sizeof(s) - 1 && memcmp (s, p, sizeof(s) - 1) == 0) typedef int (*strcmp_fn) (const char *, const char *, int flags); static int cmp_exact (const char *pat, const char *str, int flags) { return strcmp (pat, str) == 0; } static int cmp_exact_ci (const char *pat, const char *str, int flags) { return strcmp (pat, str) == 0; } static int cmp_fnmatch (const char *pat, const char *str, int flags) { return fnmatch (pat, str, flags) == 0; } @@ -175,91 +177,91 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req) dict->nrow = dict->ncol = 0; return 0; } acc = txtacc_create (); for (i = 0; i < dict->parmc; i++) { char *pat = dict->parmv[i]; if (pat[0] == '/') { pat++; if (*pat != '/' && parse_cmp_type (pat, &cmpfn, &flags) == 0) continue; } if (i + ncol >= dict->parmc) break; if (cmpfn (pat, req, flags)) { size_t j; for (j = 1; j <= ncol; j++) { char *val = dict->parmv[i + j]; txtacc_grow (acc, val, strlen (val) + 1); } count++; } i += ncol; } dict->nrow = count; dict->ncol = ncol; if (count == 0) { txtacc_free (acc); bds = NULL; rc = 1; } else { size_t i; char *p; - bds = xmalloc (sizeof (*bds)); + bds = grecs_malloc (sizeof (*bds)); count *= ncol; - bds->wp = xcalloc (count, sizeof (bds->wp[0])); + bds->wp = grecs_calloc (count, sizeof (bds->wp[0])); bds->acc = acc; p = txtacc_finish (acc, 0); for (i = 0; i < count; i++) { bds->wp[i] = p; p += strlen (p) + 1; } rc = 0; } dict->storage = bds; return rc; } int builtin_free_result (struct dictionary *dict, void *handle) { if (dict->storage) { struct builtin_data_storage *bds = dict->storage; txtacc_free (bds->acc); free (bds->wp); free (bds); dict->storage = NULL; } return 0; } int builtin_get (struct dictionary *dict, void *handle, unsigned nrow, unsigned ncol) { struct builtin_data_storage *bds = dict->storage; char *str = bds->wp[nrow * dict->ncol + ncol]; dictionary_copy_result (dict, str, strlen (str)); return 0; } diff --git a/src/config.c b/src/config.c index df9816e..8250749 100644 --- a/src/config.c +++ b/src/config.c @@ -101,97 +101,97 @@ safe_file_name (char *file_name) ; continue; } else if (p[1] == '.' && (p[2] == 0 || p[2] == '/')) { if (p == file_name) return NULL; if (p[-1] == '/') /* found */ { char *q, *s; s = p + 2; /* Find previous delimiter */ for (q = p-2; *q != '/' && q >= file_name; q--) ; if (q < file_name) { q = file_name; s++; } /* Copy stuff */ p = q; while ((*q++ = *s++)) ; continue; } } p++; } if (file_name[0] == 0) { file_name[0] = '/'; file_name[1] = 0; } return file_name; } /* Same as safe_file_name, but returns an allocated copy. */ char * safe_file_name_alloc (const char *file_name) { - char *s = xstrdup (file_name); + char *s = grecs_strdup (file_name); char *ns = safe_file_name (s); if (!ns) free (s); return ns; } static struct keyword event_tab[] = { { "success", ev_success }, { "bad-ownership", ev_bad_ownership }, { "bad-directive-signature", ev_bad_directive_signature }, { "bad-detached-signature", ev_bad_detached_signature }, { "check-failure", ev_check_fail }, { NULL } }; const char * notification_event_str (enum notification_event evt) { const char *ret; if (tok_to_keyword (evt, event_tab, &ret)) { grecs_error (NULL, 0, _("INTERNAL ERROR: unknown notification event number: %d"), evt); return NULL; } return ret; } int string_to_notification_event (grecs_locus_t *locus, const char *val, enum notification_event *pret) { int res; if (keyword_to_tok (val, event_tab, &res)) { grecs_error (locus, 0, _("unknown notification event: %s"), val); return 1; } *pret = res; return 0; } static struct keyword target_tab[] = { { "read", notify_read }, /* Read recipients from the message headers */ { "message", notify_read }, { "admin", notify_admin}, /* System administrator */ @@ -504,142 +504,142 @@ parse_statmask (grecs_locus_t *loc, grecs_value_t *val, unsigned long *pmask) unsigned long x; if (parse_single_statmask (loc, vp, &x, &invert)) err = 1; else if (invert) mask &= ~x; else mask |= x; } } break; } if (!err) *pmask = mask; return err; } static int cb_statistics (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { return parse_statmask (locus, value, varptr); } static int cb_sql_host (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct sqlconn *pconn = varptr; char *p; if (assert_string_arg (locus, cmd, value)) return 1; p = strchr (value->v.string, ':'); if (p) { /* FIXME: Modifies constant string */ *p++ = 0; if (p[0] == '/') { - pconn->socket = xstrdup (p); - pconn->host = xstrdup ("localhost"); + pconn->socket = grecs_strdup (p); + pconn->host = grecs_strdup ("localhost"); } else { char *end; unsigned long n = strtoul (p, &end, 10); if (*end) { grecs_error (locus, 0, _("invalid port number (near %s)"), end); return 0; } if (n == 0 || n > USHRT_MAX) { grecs_error (locus, 0, _("port number out of range 1..%d"), USHRT_MAX); return 0; } pconn->port = n; /* Save host name */ - pconn->host = xstrdup (value->v.string); + pconn->host = grecs_strdup (value->v.string); } } else - pconn->host = xstrdup (value->v.string); + pconn->host = grecs_strdup (value->v.string); return 0; } static int cb_sql (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct sqlconn *pconn; void **pdata = cb_data; switch (cmd) { case grecs_callback_section_begin: if (!value || value->type != GRECS_TYPE_STRING) { grecs_error(locus, 0, _("tag must be a string")); return 0; } - pconn = xzalloc (sizeof (*pconn)); + pconn = grecs_zalloc (sizeof (*pconn)); pconn->ident = strdup (value->v.string); *pdata = pconn; break; case grecs_callback_section_end: pconn = *pdata; sql_register_conn (pconn); free (pconn); *pdata = NULL; break; case grecs_callback_set_value: grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } static struct grecs_keyword sql_kw[] = { { "config-file", N_("file"), N_("Read MySQL configuration from <file>"), grecs_type_string, NULL, offsetof(struct sqlconn, config_file) }, { "config-group", N_("name"), N_("Read the named group from the SQL configuration file"), grecs_type_string, NULL, offsetof(struct sqlconn, config_group) }, { "host", N_("host"), N_("Set SQL server hostname or IP address"), grecs_type_string, NULL, 0, cb_sql_host }, { "database", N_("dbname"), N_("Set database name"), grecs_type_string, NULL, offsetof(struct sqlconn, database), }, { "user", N_("name"), N_("Set SQL user name"), grecs_type_string, NULL, offsetof(struct sqlconn, user) }, { "password", N_("arg"), N_("Set SQL user password"), grecs_type_string, NULL, offsetof(struct sqlconn, password) }, { "ssl-ca", N_("file"), N_("File name of the Certificate Authority (CA) certificate"), grecs_type_string, NULL, offsetof(struct sqlconn, cacert) }, { NULL } }; static int cb_syslog_facility (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { if (assert_string_arg (locus, cmd, value)) return 1; if (mu_string_to_syslog_facility (value->v.string, varptr)) @@ -851,194 +851,194 @@ cb_event (enum grecs_callback_command cmd, if (assert_string_arg (locus, cmd, value)) return 1; string_to_notification_event (locus, value->v.string, pev); return 0; } static int cb_recipient (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { enum notification_target *tgt = varptr; if (assert_string_arg (locus, cmd, value)) return 1; string_to_notification_target (locus, value->v.string, tgt); return 0; } static struct grecs_keyword notify_event_kw[] = { { "event", N_("ev-id"), N_("Event on which to notify"), grecs_type_string, NULL, offsetof(struct notification, ev), cb_event }, { "recipient", N_("who"), N_("Notify this recipient"), grecs_type_string, NULL, offsetof(struct notification, tgt), cb_recipient }, { "message", N_("text-or-id"), N_("Text of the notification or identifier of a defined message template"), grecs_type_string, NULL, offsetof(struct notification, msg) }, { "gpg-sign", N_("key"), N_("Sign message with this key"), grecs_type_string, NULL, offsetof(struct notification, sign_keys) }, { NULL } }; static int cb_notify_event (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct notification *ntf; void **pdata = cb_data; switch (cmd) { case grecs_callback_section_begin: - ntf = xzalloc (sizeof (*ntf)); + ntf = grecs_zalloc (sizeof (*ntf)); *pdata = ntf; break; case grecs_callback_section_end: ntf = *pdata; if (!ntf->msg) grecs_error (locus, 0, _("missing message definition")); else { struct notification **p = (struct notification **) varptr; ntf->next = *p; *p = ntf; /* FIXME: check ev and tgt? */ } break; case grecs_callback_set_value: grecs_error (locus, 0, _("invalid use of block statement")); } return 0; } static enum dictionary_type string_to_dictionary_type (const char *str) { if (strcmp (str, "sql") == 0) return dictionary_sql; else if (strcmp (str, "builtin") == 0) return dictionary_builtin; else if (strcmp (str, "external") == 0) return dictionary_external; else return dictionary_none; } static int cb_dictionary_type (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { enum dictionary_type *ptype = varptr; if (assert_string_arg (locus, cmd, value)) return 1; *ptype = string_to_dictionary_type (value->v.string); if (*ptype == dictionary_none) grecs_error (locus, 0, _("unknown dictionary type: %s"), value->v.string); return 0; } static int cb_dictionary_params (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct dictionary *meth = varptr; size_t size; if (cmd != grecs_callback_set_value) { grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GRECS_TYPE_LIST) { grecs_error (locus, 0, _("expected list value")); return 1; } size = grecs_list_size (value->v.list); if (size == 0) { meth->parmc = 0; meth->parmv = NULL; } else { int i; struct grecs_list_entry *ep; meth->parmc = size; - meth->parmv = xcalloc (size + 1, sizeof (meth->parmv[0])); + meth->parmv = grecs_calloc (size + 1, sizeof (meth->parmv[0])); for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) { const grecs_value_t *vp = ep->data; if (assert_string_arg (locus, cmd, vp)) break; - meth->parmv[i] = xstrdup (vp->v.string); + meth->parmv[i] = grecs_strdup (vp->v.string); } meth->parmv[i] = NULL; } return 0; } static struct grecs_keyword dictionary_kw[] = { { "type", N_("type"), N_("Dictionary type"), grecs_type_string, NULL, offsetof(struct dictionary, type), cb_dictionary_type }, { "query", N_("string"), N_("Query template"), grecs_type_string, NULL, offsetof(struct dictionary, query) }, { "params", N_("arg"), N_("Set dictionary parameters"), grecs_type_string|GRECS_LIST, NULL, 0, cb_dictionary_params }, { NULL } }; int string_to_dictionary_id (grecs_locus_t *locus, const char *str, enum dictionary_id *idp) { static struct keyword id_tab[] = { { "project-uploader", project_uploader_dict }, { "project-owner", project_owner_dict }, { NULL } }; int res; if (keyword_to_tok (str, id_tab, &res)) { grecs_error (locus, 0, _("unknown dictionary ID: %s"), str); return 1; } *idp = res; return 0; } static int cb_dictionary (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct dictionary **pmeth, *meth; void **pdata = cb_data; enum dictionary_id id; @@ -1114,98 +1114,98 @@ cb_url (enum grecs_callback_command cmd, static struct grecs_keyword spool_kw[] = { { "url", N_("arg"), N_("URL corresponding to this spool"), grecs_type_string, NULL, offsetof(struct spool, url) }, { "alias", N_("arg"), N_("Aliases"), grecs_type_string|GRECS_LIST, NULL, offsetof(struct spool, aliases) }, { "source", N_("dir"), N_("Source directory"), grecs_type_string, NULL, offsetof(struct spool, source_dir) }, { "destination", N_("dir"), N_("Destination directory"), grecs_type_string, NULL, offsetof(struct spool, dest_url), cb_url }, { "file-sweep-time", N_("interval"), N_("Define file sweep time"), grecs_type_string, NULL, offsetof(struct spool, file_sweep_time), cb_interval }, { "dictionary", N_("ident"), N_("Define data dictionary"), grecs_type_section, NULL, offsetof(struct spool, dictionary), cb_dictionary, NULL, dictionary_kw }, { "archive", N_("type: string"), N_("Set up archivation"), grecs_type_section, NULL, offsetof(struct spool, archive), cb_archive, NULL, archive_kw }, { "notify-event", NULL, N_("Configure notification"), grecs_type_section, NULL, offsetof(struct spool, notification), cb_notify_event, NULL, notify_event_kw }, { "check-script", NULL, N_("A /bin/sh script to verify the tarball"), grecs_type_string, NULL, offsetof(struct spool, check_script) }, { NULL } }; static int cb_spool (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct spool *spool; void **pdata = cb_data; int rc, ec, i; switch (cmd) { case grecs_callback_section_begin: if (!value || value->type != GRECS_TYPE_STRING) { grecs_error (locus, 0, _("tag must be a string")); return 1; } - spool = xzalloc (sizeof (*spool)); - spool->tag = xstrdup (value->v.string); + spool = grecs_zalloc (sizeof (*spool)); + spool->tag = grecs_strdup (value->v.string); spool->file_sweep_time = file_sweep_time; for (i = 0; i < NITEMS (spool->dictionary); i++) spool->dictionary[i] = default_dictionary[i]; spool->archive = default_archive_descr; *pdata = spool; break; case grecs_callback_section_end: rc = 0; spool = *pdata; if (!spool->source_dir) { grecs_error (locus, 0, _("source is not given")); rc = 1; } else if (test_dir (spool->source_dir, &ec)) { if (ec) grecs_error (locus, ec, _("cannot access %s"), spool->source_dir); else grecs_error (locus, 0, _("%s is not a directory"), spool->source_dir); rc = 1; } if (!spool->dest_url) { grecs_error (locus, 0, _("destination is not given")); rc = 1; } else if (url_to_vtab (spool->dest_url, &spool->vtab)) { grecs_error (locus, 0, _("unsupported url: %s"), mu_url_to_string (spool->dest_url)); rc = 1; } else if (spool->vtab.test_url && spool->vtab.test_url (spool->dest_url, locus)) rc = 1; for (i = 0; i < dictionary_count; i++) if (spool->dictionary[i]->type == dictionary_external) { grecs_error (locus, 0, _("Sorry, the dictionary type `external' is not yet supported")); rc = 1; } @@ -1232,98 +1232,98 @@ cb_user (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { struct passwd *pw; if (assert_string_arg (locus, cmd, value)) return 1; pw = getpwnam (value->v.string); if (!pw) { grecs_error (locus, 0, _("no such user: %s"), value->v.string); return 1; } wydawca_uid = pw->pw_uid; wydawca_gid = pw->pw_gid; return 0; } static int cb_supp_groups (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { if (cmd != grecs_callback_set_value) { grecs_error (locus, 0, _("Unexpected block statement")); return 1; } if (!value || value->type != GRECS_TYPE_LIST) { grecs_error (locus, 0, _("expected list value")); return 1; } wydawca_supp_groupc = grecs_list_size (value->v.list); if (wydawca_supp_groupc == 0) wydawca_supp_groups = NULL; else { int i; struct grecs_list_entry *ep; - wydawca_supp_groups = xcalloc (wydawca_supp_groupc, - sizeof (wydawca_supp_groups[0])); + wydawca_supp_groups = grecs_calloc (wydawca_supp_groupc, + sizeof (wydawca_supp_groups[0])); for (i = 0, ep = value->v.list->head; ep; ep = ep->next, i++) { const grecs_value_t *vp = ep->data; struct group *grp; if (assert_string_arg (locus, cmd, vp)) break; grp = getgrnam (vp->v.string); if (!grp) { grecs_error (locus, 0, _("no such group: %s"), value->v.string); break; } wydawca_supp_groups[i] = grp->gr_gid; } } return 0; } static struct grecs_keyword locking_kw[] = { { "enable", NULL, N_("Enable or disable locking"), grecs_type_bool, &enable_locking }, { "directory", N_("dir"), N_("Set directory for lock files"), grecs_type_string, &lockdir }, { "expire-time", N_("interval"), N_("Define lock expiration interval"), grecs_type_string, &lock_expire_time, 0, cb_interval }, { "timeout", N_("interval"), N_("Locking timeout"), grecs_type_string, &lock_timeout, 0, cb_interval }, { NULL } }; static int cb_locking (enum grecs_callback_command cmd, grecs_locus_t *locus, void *varptr, grecs_value_t *value, void *cb_data) { if (cmd == grecs_callback_set_value) { if (!value || value->type != GRECS_TYPE_STRING) { grecs_error (locus, 0, _("expected scalar value as a tag")); return 1; } grecs_string_convert (&enable_locking, grecs_type_bool, value->v.string, diff --git a/src/dictionary.c b/src/dictionary.c index b7baf05..2b995d4 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -3,226 +3,227 @@ 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 distribute |