aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am5
-rw-r--r--src/backup.c165
-rw-r--r--src/builtin.c10
-rw-r--r--src/config.c26
-rw-r--r--src/dictionary.c11
-rw-r--r--src/directive.c8
-rw-r--r--src/diskio.c6
-rw-r--r--src/exec.c2
-rw-r--r--src/gpg.c7
-rw-r--r--src/job.c2
-rw-r--r--src/lock.c12
-rw-r--r--src/mail.c14
-rw-r--r--src/net.c4
-rw-r--r--src/process.c4
-rw-r--r--src/sql.c4
-rw-r--r--src/timer.c5
-rw-r--r--src/triplet.c17
-rw-r--r--src/txtacc.c16
-rw-r--r--src/verify.c4
-rw-r--r--src/wydawca.c8
-rw-r--r--src/wydawca.h20
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
@@ -17,4 +17,5 @@
sbin_PROGRAMS=wydawca
wydawca_SOURCES=\
+ backup.c\
builtin.c\
builtin.h\
@@ -61,6 +62,6 @@ 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)\"\
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
@@ -17,6 +17,8 @@
#include "wydawca.h"
#include "builtin.h"
-#include "fnmatch.h"
-#include "regex.h"
+
+#ifndef FNM_CASEFOLD
+# define FNM_CASEFOLD 0
+#endif
int
@@ -221,7 +223,7 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
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);
diff --git a/src/config.c b/src/config.c
index df9816e..8250749 100644
--- a/src/config.c
+++ b/src/config.c
@@ -147,5 +147,5 @@ 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)
@@ -550,6 +550,6 @@ cb_sql_host (enum grecs_callback_command cmd,
if (p[0] == '/')
{
- pconn->socket = xstrdup (p);
- pconn->host = xstrdup ("localhost");
+ pconn->socket = grecs_strdup (p);
+ pconn->host = grecs_strdup ("localhost");
}
else
@@ -570,9 +570,9 @@ cb_sql_host (enum grecs_callback_command cmd,
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;
}
@@ -595,5 +595,5 @@ cb_sql (enum grecs_callback_command cmd,
return 0;
}
- pconn = xzalloc (sizeof (*pconn));
+ pconn = grecs_zalloc (sizeof (*pconn));
pconn->ident = strdup (value->v.string);
*pdata = pconn;
@@ -897,5 +897,5 @@ cb_notify_event (enum grecs_callback_command cmd,
switch (cmd) {
case grecs_callback_section_begin:
- ntf = xzalloc (sizeof (*ntf));
+ ntf = grecs_zalloc (sizeof (*ntf));
*pdata = ntf;
break;
@@ -985,5 +985,5 @@ cb_dictionary_params (enum grecs_callback_command cmd,
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++)
@@ -994,5 +994,5 @@ cb_dictionary_params (enum grecs_callback_command cmd,
break;
- meth->parmv[i] = xstrdup (vp->v.string);
+ meth->parmv[i] = grecs_strdup (vp->v.string);
}
meth->parmv[i] = NULL;
@@ -1160,6 +1160,6 @@ cb_spool (enum grecs_callback_command cmd,
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++)
@@ -1278,6 +1278,6 @@ cb_supp_groups (enum grecs_callback_command cmd,
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++)
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -49,6 +49,5 @@ struct dictionary *
dictionary_new (enum dictionary_id id, enum dictionary_type type)
{
- struct dictionary *mp = xmalloc (sizeof mp[0]);
- memset (mp, 0, sizeof mp[0]);
+ struct dictionary *mp = grecs_zalloc (sizeof mp[0]);
mp->id = id;
mp->type = type;
@@ -93,4 +92,6 @@ dictionary_close (struct dictionary *dict, void *handle)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
+ if (mp->free)
+ mp->free (dict, handle);
if (!mp->close)
return 0;
@@ -187,5 +188,5 @@ dictionary_copy_result (struct dictionary *dict, const char *res, size_t size)
{
dict->result_size = size + 1;
- dict->result = x2realloc (dict->result, &dict->result_size);
+ dict->result = grecs_realloc (dict->result, dict->result_size);
}
memcpy (dict->result, res, size);
@@ -207,5 +208,5 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
if (!input)
{
- *poutput = xmalloc (1);
+ *poutput = grecs_malloc (1);
(*poutput)[0] = 0;
*psize = 1;
@@ -217,5 +218,5 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
size = wordsplit_c_quoted_length (input, 0, &quote);
- output = xmalloc (size + 1);
+ output = grecs_malloc (size + 1);
wordsplit_c_quote_copy (output, input, 0);
output[size] = 0;
diff --git a/src/directive.c b/src/directive.c
index 08a14df..fadaedf 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -35,5 +35,5 @@ directive_parse (struct file_triplet *trp)
dcount++;
- trp->directive = xcalloc (dcount + 1, sizeof trp->directive[0]);
+ trp->directive = grecs_calloc (dcount + 1, sizeof trp->directive[0]);
p = trp->blurb;
for (i = j = 0; i < dcount; i++)
@@ -112,5 +112,5 @@ _directive_seq_get (int n, struct file_triplet *trp,
{
trp->tmpsize = len + 1;
- trp->tmp = x2realloc (trp->tmp, &trp->tmpsize);
+ trp->tmp = grecs_realloc (trp->tmp, trp->tmpsize);
}
memcpy (trp->tmp, trp->directive[n], len);
@@ -381,5 +381,5 @@ stderr_redirector (const char *tag)
if (!fp)
_exit (127);
- while (getline (&buf, &size, fp) >= 0)
+ while (grecs_getline (&buf, &size, fp) >= 0)
{
trim_crlf (buf);
@@ -494,5 +494,5 @@ run_check_script (const char *script, struct file_triplet *trp,
if (debug_level > 2)
logmsg (LOG_DEBUG, _("reading script output..."));
- while (getline (&buf, &size, fp) > 0)
+ while (grecs_getline (&buf, &size, fp) > 0)
{
size_t len = strlen (buf);
diff --git a/src/diskio.c b/src/diskio.c
index 9addd9b..b175a45 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -47,5 +47,5 @@ concat_dir (const char *base, const char *name, size_t *pbaselen)
size = len + 1 + strlen (name);
- dir = xmalloc (size + 1);
+ dir = grecs_malloc (size + 1);
memcpy (dir, base, len);
dir[len++] = '/';
@@ -172,5 +172,5 @@ copy_file (const char *file, const char *dst_file)
;
if (bufsize == 0)
- xalloc_die ();
+ grecs_alloc_die ();
rc = 0;
@@ -493,5 +493,5 @@ make_signame (const char *file_name)
&& memcmp (file_name + len - SUF_SIG_LEN, SUF_SIG, SUF_SIG_LEN)))
{
- char *signame = xmalloc (len + SUF_SIG_LEN + 1);
+ char *signame = grecs_malloc (len + SUF_SIG_LEN + 1);
strcpy (signame, file_name);
return strcat (signame, SUF_SIG);
diff --git a/src/exec.c b/src/exec.c
index ed7ee1e..7ebf152 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -76,5 +76,5 @@ log_output (int prio, const char *prog, FILE *fp)
logmsg (prio, _("%s output follows:"), prog);
- while (getline (&buf, &size, fp) > 0)
+ while (grecs_getline (&buf, &size, fp) > 0)
logmsg (prio, "%s", buf);
logmsg (prio, _("end of %s output"), prog);
diff --git a/src/gpg.c b/src/gpg.c
index 474d94b..d4f9b71 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -133,5 +133,5 @@ create_gpg_homedir ()
return 0;
- temp_homedir = xstrdup ("/tmp/wydawca-XXXXXX");
+ temp_homedir = grecs_strdup ("/tmp/wydawca-XXXXXX");
if (!mkdtemp (temp_homedir))
{
@@ -238,5 +238,5 @@ verify_directive_signature (struct file_triplet *trp)
res = gpgme_op_import_result (ctx);
pstat = res->imports;
- uptr->fpr = xstrdup (pstat->fpr);
+ uptr->fpr = grecs_strdup (pstat->fpr);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("imported key: user = %s, fingerprint = %s"),
@@ -272,5 +272,6 @@ verify_directive_signature (struct file_triplet *trp)
gpgme_data_release (directive_data);
gpgme_data_release (key_data);
-
+ gpgme_release (ctx);
+
return rc;
}
diff --git a/src/job.c b/src/job.c
index 7e3fdf5..764e463 100644
--- a/src/job.c
+++ b/src/job.c
@@ -206,5 +206,5 @@ schedule_job (const struct spool *spool, uid_t uid)
if (!job)
{
- job = xzalloc (sizeof (*job));
+ job = grecs_zalloc (sizeof (*job));
job->spool = spool;
job->uid = uid;
diff --git a/src/lock.c b/src/lock.c
index 32367de..dece75d 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -188,5 +188,5 @@ host_name ()
{
size = 256;
- hostbuf = xmalloc (size);
+ hostbuf = grecs_malloc (size);
}
else
@@ -194,7 +194,7 @@ host_name ()
size_t ns = size * 2;
if (size < ns)
- xalloc_die ();
+ grecs_alloc_die ();
size = ns;
- hostbuf = xrealloc (hostbuf, size);
+ hostbuf = grecs_realloc (hostbuf, size);
}
}
@@ -262,5 +262,5 @@ static char *
fix_tagname (const char *tag)
{
- char *tagname = xstrdup (tag);
+ char *tagname = grecs_strdup (tag);
char *p;
@@ -279,5 +279,5 @@ wydawca_lockname (const char *tag)
grecs_asprintf (&lockname, &size, "%s/LCK.%s", lockdir, tagname);
if (!lockname)
- xalloc_die ();
+ grecs_alloc_die ();
free (tagname);
return lockname;
@@ -290,5 +290,5 @@ wydawca_lock_init ()
{
if (!lockdir)
- lockdir = xstrdup (LOCALSTATEDIR "/lock/" PACKAGE);
+ lockdir = grecs_strdup (LOCALSTATEDIR "/lock/" PACKAGE);
if (create_hierarchy (lockdir, 0))
exit (EX_OSFILE);
diff --git a/src/mail.c b/src/mail.c
index bac0381..6855ed7 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -292,5 +292,5 @@ mail_send_message (mu_address_t rcpt, const char *text,
{
mu_address_to_string (rcpt, NULL, 0, &size);
- buf = xmalloc (size + 1);
+ buf = grecs_malloc (size + 1);
mu_address_to_string (rcpt, buf, size + 1, NULL);
@@ -301,5 +301,5 @@ mail_send_message (mu_address_t rcpt, const char *text,
{
mu_address_to_string (from_address, NULL, 0, &size);
- buf = xmalloc (size + 1);
+ buf = grecs_malloc (size + 1);
mu_address_to_string (from_address, buf, size + 1, NULL);
mu_header_set_value (hdr, "From", buf, 1);
@@ -435,5 +435,5 @@ mail_stats ()
char *buf;
mu_address_to_string (admin_address, NULL, 0, &size);
- buf = xmalloc (size + 1);
+ buf = grecs_malloc (size + 1);
mu_address_to_string (admin_address, buf, size + 1, NULL);
logmsg (LOG_DEBUG, _("sending stats to %s"), buf);
@@ -445,5 +445,5 @@ mail_stats ()
time (&t);
exp[0].kw = "date";
- exp[0].value = exp[0].storage = xstrdup (ctime (&t));
+ exp[0].value = exp[0].storage = grecs_strdup (ctime (&t));
exp[0].value [strlen (exp[0].value) - 1] = 0;
timer_fill_meta (exp + 1, tc);
@@ -599,5 +599,5 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
char *buf;
mu_address_to_string (rcpt, NULL, 0, &size);
- buf = xmalloc (size + 1);
+ buf = grecs_malloc (size + 1);
mu_address_to_string (rcpt, buf, size + 1, NULL);
logmsg (LOG_DEBUG, _("notifying %s (project %s) about %s"),
@@ -643,5 +643,5 @@ expand_email_admin (struct metadef *def, void *data)
{
size++;
- def->storage = xmalloc (size);
+ def->storage = grecs_malloc (size);
mu_address_to_string (admin_address, def->storage, size, NULL);
def->value = def->storage;
@@ -671,5 +671,5 @@ expand_email_owner (struct metadef *def, void *data)
{
size++;
- def->storage = xmalloc (size);
+ def->storage = grecs_malloc (size);
mu_address_to_string (addr, def->storage, size, NULL);
def->value = def->storage;
diff --git a/src/net.c b/src/net.c
index 3e9fe30..d08a6ba 100644
--- a/src/net.c
+++ b/src/net.c
@@ -104,5 +104,5 @@ handle_connection (FILE *in, FILE *out)
struct passwd *pw;
- if (getline (&buf, &buflen, in) <= 0)
+ if (grecs_getline (&buf, &buflen, in) <= 0)
return;
trim_crlf (buf);
@@ -126,5 +126,5 @@ handle_connection (FILE *in, FILE *out)
fprintf (out, "+ OK, spool %s\r\n", spool->tag);
- if (getline (&buf, &buflen, in) < 0)
+ if (grecs_getline (&buf, &buflen, in) < 0)
{
logmsg (LOG_ERR, "protocol error");
diff --git a/src/process.c b/src/process.c
index e41709d..200d987 100644
--- a/src/process.c
+++ b/src/process.c
@@ -28,5 +28,5 @@ void
register_spool (struct spool *spool)
{
- struct spool_list *sp = xmalloc (sizeof *sp);
+ struct spool_list *sp = grecs_malloc (sizeof *sp);
sp->spool = *spool;
sp->next = spool_list;
@@ -114,5 +114,5 @@ parse_file_name (const char *name, struct file_info *finfo)
suftab[i].suf, suftab[i].len) == 0)
{
- finfo->name = xstrdup (name);
+ finfo->name = grecs_strdup (name);
finfo->type = suftab[i].type;
finfo->root_len = len - suftab[i].len;
diff --git a/src/sql.c b/src/sql.c
index a4b311e..80eb344 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -31,5 +31,5 @@ void
sql_register_conn (struct sqlconn *conn)
{
- struct sql_list *ent = xmalloc (sizeof *ent);
+ struct sql_list *ent = grecs_malloc (sizeof *ent);
ent->conn = *conn;
ent->next = sql_list;
@@ -199,5 +199,5 @@ sql_quote (struct dictionary *dict, void *handle, const char *input,
len = strlen (input);
size = 2 * len + 1;
- output = xmalloc (size);
+ output = grecs_malloc (size);
mysql_real_escape_string (&conn->mysql, output, input, len);
*poutput = output;
diff --git a/src/timer.c b/src/timer.c
index 1634462..cece63a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -21,5 +21,4 @@
#include <string.h>
#include <ctype.h>
-#include <xalloc.h>
struct timer_slot
@@ -183,5 +182,5 @@ timer_format_time (double t)
}
if (!str)
- xalloc_die ();
+ grecs_alloc_die ();
return str;
}
@@ -211,5 +210,5 @@ _fill_meta (void *sym, void *data)
grecs_asprintf (&buf, &size, "timer:%s:%s", slot->name, #arg); \
if (!buf) \
- xalloc_die (); \
+ grecs_alloc_die (); \
tp->def->kw = buf; \
tp->def->storage = timer_format_time (__cat2__(timer_get_,arg) (slot)); \
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -61,4 +61,5 @@ hash_triplet_free (void *data)
{
struct uploader_info *next = up->next;
+ free (up->fpr);
free (up);
up = next;
@@ -95,5 +96,5 @@ register_file (struct file_info *finfo, const struct spool *spool)
}
- key.name = xmalloc (finfo->root_len + 1);
+ key.name = grecs_malloc (finfo->root_len + 1);
memcpy (key.name, finfo->name, finfo->root_len);
key.name[finfo->root_len] = 0;
@@ -379,5 +380,5 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
/* Size */
if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size))
- xalloc_die ();
+ grecs_alloc_die ();
/* Figure out padding and format the buffer */
@@ -392,5 +393,5 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
sptr,
timebuf, info->name))
- xalloc_die ();
+ grecs_alloc_die ();
free (sptr);
*pret = buf;
@@ -412,5 +413,5 @@ expand_triplet_ls_full (struct metadef *def, void *data)
size += strlen (buf[file_directive]) + 1;
- def->value = def->storage = xmalloc (size + 1);
+ def->value = def->storage = grecs_malloc (size + 1);
def->value[0] = 0;
if (buf[file_dist])
@@ -447,5 +448,5 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
size += strlen (buf[file_signature]) + 1;
- def->value = def->storage = xmalloc (size + 1);
+ def->value = def->storage = grecs_malloc (size + 1);
def->value[0] = 0;
if (buf[file_dist])
@@ -553,5 +554,5 @@ expand_email_user (struct metadef *def, void *data)
if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>",
trp->uploader->realname, trp->uploader->email))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
}
@@ -595,5 +596,5 @@ expand_check_result (struct metadef *def, void *data)
if (grecs_asprintf (&def->storage, &size,
"%d", WEXITSTATUS (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
else if (WIFSIGNALED (status))
@@ -603,5 +604,5 @@ expand_check_result (struct metadef *def, void *data)
if (grecs_asprintf (&def->storage, &size, "SIG+%d",
WTERMSIG (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
else
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -35,6 +35,6 @@ static struct txtacc_entry *
txtacc_alloc_entry (struct grecs_list *list, size_t size)
{
- struct txtacc_entry *p = xmalloc (sizeof (*p));
- p->buf = xmalloc (size);
+ struct txtacc_entry *p = grecs_malloc (sizeof (*p));
+ p->buf = grecs_malloc (size);
p->size = size;
p->len = 0;
@@ -90,5 +90,5 @@ struct txtacc *
txtacc_create ()
{
- struct txtacc *acc = xmalloc (sizeof (*acc));
+ struct txtacc *acc = grecs_malloc (sizeof (*acc));
acc->cur = grecs_list_create ();
acc->cur->free_entry = txtacc_entry_free;
@@ -138,4 +138,5 @@ txtacc_finish (struct txtacc *acc, int steal)
acc->cur->head->data = NULL;
txtacc_entry_tailor (txtent);
+ grecs_list_append (acc->mem, txtent);
break;
@@ -159,7 +160,8 @@ txtacc_finish (struct txtacc *acc, int steal)
p = txtent->buf;
if (steal)
- free (txtent);
- else
- grecs_list_append (acc->mem, txtent);
+ {
+ grecs_list_remove_tail (acc->mem);
+ free (txtent);
+ }
return p;
}
@@ -174,5 +176,5 @@ txtacc_free_string (struct txtacc *acc, char *str)
if (tp->buf == str)
{
- grecs_list_remove_entry(acc->mem, ep);
+ grecs_list_remove_entry (acc->mem, ep);
free (tp->buf);
return;
diff --git a/src/verify.c b/src/verify.c
index a49983c..c8fef11 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -114,5 +114,5 @@ fill_project_name (struct file_triplet *trp)
}
- blurb = xmalloc (size + 1);
+ blurb = grecs_malloc (size + 1);
rc = fread (blurb, size, 1, fp);
@@ -183,5 +183,5 @@ struct uploader_info *
new_uploader_info (struct uploader_info *src)
{
- struct uploader_info *p = xmalloc (sizeof (*p));
+ struct uploader_info *p = grecs_malloc (sizeof (*p));
p->next = NULL;
p->name = src->name;
diff --git a/src/wydawca.c b/src/wydawca.c
index cc1815b..36aa8b7 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -72,5 +72,5 @@ syslog_printer (int prio, const char *fmt, va_list ap)
{
fmtsize = size;
- fmtbuf = x2realloc (fmtbuf, &fmtsize);
+ fmtbuf = grecs_realloc (fmtbuf, fmtsize);
}
sprintf (fmtbuf, "[%s] %s", p, fmt);
@@ -180,5 +180,5 @@ stat_expand (struct metadef *def, void *data)
if (grecs_asprintf (&def->storage, &size, "%u",
wydawca_stat[(int) def->data]))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
return def->value;
@@ -190,5 +190,5 @@ make_stat_expansion (size_t count)
int i;
struct metadef *def, *p;
- def = xcalloc (MAX_STAT + count + 1, sizeof (def[0]));
+ def = grecs_calloc (MAX_STAT + count + 1, sizeof (def[0]));
p = def + count;
for (i = 0; i < MAX_STAT; i++, p++)
@@ -253,5 +253,5 @@ collect_uids (int argc, char **argv)
uidc = argc;
- uidv = xcalloc (uidc, sizeof (uidv[0]));
+ uidv = grecs_calloc (uidc, sizeof (uidv[0]));
for (i = 0; i < argc; i++)
{
diff --git a/src/wydawca.h b/src/wydawca.h
index 2307bad..94b7ee3 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -42,4 +42,6 @@
#include <time.h>
#include <sysexits.h>
+#include <fnmatch.h>
+#include <regex.h>
#include <mailutils/types.h>
@@ -47,7 +49,4 @@
#include <mailutils/errno.h>
-#include "error.h"
-#include "xalloc.h"
-#include "backupfile.h"
#include "grecs.h"
#include "wordsplit.h"
@@ -111,4 +110,19 @@ struct dictionary
+enum backup_type
+ {
+ no_backups, /* Don't make backups */
+ simple_backups, /* Make only simple backups */
+ numbered_existing_backups,/* Make numbered backups for files that already
+ have such backups and simple backups for the
+ rest */
+ numbered_backups, /* Make only numbered backups */
+ };
+
+extern char const *simple_backup_suffix;
+
+char *find_backup_file_name (char const *, enum backup_type);
+
+
/* Archive types */

Return to:

Send suggestions and report system problems to the System administrator.