aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 10:21:43 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 10:33:34 +0300
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch)
tree65356dd7b5a9010499550c468e960c93515a7e15 /src
parentf569a6f2628b9ddef4dfb4424aff2dad644a8f19 (diff)
downloadwydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.gz
wydawca-de3fbe3e8d4dd2a89f7755906d76055784c437cc.tar.bz2
Drop gnulib.
* bootstrap: Rewrite. * bootstrap.conf: Remove. * configure.ac: Remove gl_EARLY/gl_INIT * src/backup.c: New file. * src/txtacc.c (txtacc_finish): Make sure a new entry is appended only once to the list. * (all sources): Use grecs memory allocation functions. * src/wydawca.h" Include fnmatch.h and regex.h (backup_type): New enum. (simple_backup_suffix): New extern. (find_backup_file_name): New proto. * tests/bkupname.c: New file. * tests/backup00.at: New file. * tests/backup01.at: New file. * tests/backup02.at: New file. * tests/backup03.at: New file. * tests/Makefile.am: Add new tests. * tests/testsuite.at: Add new tests. * grecs: Update.
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
@@ -18,2 +18,3 @@ sbin_PROGRAMS=wydawca
wydawca_SOURCES=\
+ backup.c\
builtin.c\
@@ -62,4 +63,4 @@ 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= \
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
@@ -18,4 +18,6 @@
#include "builtin.h"
-#include "fnmatch.h"
-#include "regex.h"
+
+#ifndef FNM_CASEFOLD
+# define FNM_CASEFOLD 0
+#endif
@@ -222,5 +224,5 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
- 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;
diff --git a/src/config.c b/src/config.c
index df9816e..8250749 100644
--- a/src/config.c
+++ b/src/config.c
@@ -148,3 +148,3 @@ 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);
@@ -551,4 +551,4 @@ cb_sql_host (enum grecs_callback_command cmd,
{
- pconn->socket = xstrdup (p);
- pconn->host = xstrdup ("localhost");
+ pconn->socket = grecs_strdup (p);
+ pconn->host = grecs_strdup ("localhost");
}
@@ -571,3 +571,3 @@ cb_sql_host (enum grecs_callback_command cmd,
/* Save host name */
- pconn->host = xstrdup (value->v.string);
+ pconn->host = grecs_strdup (value->v.string);
}
@@ -575,3 +575,3 @@ cb_sql_host (enum grecs_callback_command cmd,
else
- pconn->host = xstrdup (value->v.string);
+ pconn->host = grecs_strdup (value->v.string);
return 0;
@@ -596,3 +596,3 @@ cb_sql (enum grecs_callback_command cmd,
}
- pconn = xzalloc (sizeof (*pconn));
+ pconn = grecs_zalloc (sizeof (*pconn));
pconn->ident = strdup (value->v.string);
@@ -898,3 +898,3 @@ cb_notify_event (enum grecs_callback_command cmd,
case grecs_callback_section_begin:
- ntf = xzalloc (sizeof (*ntf));
+ ntf = grecs_zalloc (sizeof (*ntf));
*pdata = ntf;
@@ -986,3 +986,3 @@ 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]));
@@ -995,3 +995,3 @@ cb_dictionary_params (enum grecs_callback_command cmd,
- meth->parmv[i] = xstrdup (vp->v.string);
+ meth->parmv[i] = grecs_strdup (vp->v.string);
}
@@ -1161,4 +1161,4 @@ cb_spool (enum grecs_callback_command cmd,
}
- 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;
@@ -1279,4 +1279,4 @@ cb_supp_groups (enum grecs_callback_command cmd,
- 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]));
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -50,4 +50,3 @@ 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;
@@ -94,2 +93,4 @@ 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)
@@ -188,3 +189,3 @@ 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);
}
@@ -208,3 +209,3 @@ dictionary_quote_string (struct dictionary *dict, void *handle,
{
- *poutput = xmalloc (1);
+ *poutput = grecs_malloc (1);
(*poutput)[0] = 0;
@@ -218,3 +219,3 @@ 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);
diff --git a/src/directive.c b/src/directive.c
index 08a14df..fadaedf 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -36,3 +36,3 @@ directive_parse (struct file_triplet *trp)
- trp->directive = xcalloc (dcount + 1, sizeof trp->directive[0]);
+ trp->directive = grecs_calloc (dcount + 1, sizeof trp->directive[0]);
p = trp->blurb;
@@ -113,3 +113,3 @@ _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);
}
@@ -382,3 +382,3 @@ stderr_redirector (const char *tag)
_exit (127);
- while (getline (&buf, &size, fp) >= 0)
+ while (grecs_getline (&buf, &size, fp) >= 0)
{
@@ -495,3 +495,3 @@ run_check_script (const char *script, struct file_triplet *trp,
logmsg (LOG_DEBUG, _("reading script output..."));
- while (getline (&buf, &size, fp) > 0)
+ while (grecs_getline (&buf, &size, fp) > 0)
{
diff --git a/src/diskio.c b/src/diskio.c
index 9addd9b..b175a45 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -48,3 +48,3 @@ 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);
@@ -173,3 +173,3 @@ copy_file (const char *file, const char *dst_file)
if (bufsize == 0)
- xalloc_die ();
+ grecs_alloc_die ();
@@ -494,3 +494,3 @@ make_signame (const char *file_name)
{
- char *signame = xmalloc (len + SUF_SIG_LEN + 1);
+ char *signame = grecs_malloc (len + SUF_SIG_LEN + 1);
strcpy (signame, file_name);
diff --git a/src/exec.c b/src/exec.c
index ed7ee1e..7ebf152 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -77,3 +77,3 @@ 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);
diff --git a/src/gpg.c b/src/gpg.c
index 474d94b..d4f9b71 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -134,3 +134,3 @@ create_gpg_homedir ()
- temp_homedir = xstrdup ("/tmp/wydawca-XXXXXX");
+ temp_homedir = grecs_strdup ("/tmp/wydawca-XXXXXX");
if (!mkdtemp (temp_homedir))
@@ -239,3 +239,3 @@ verify_directive_signature (struct file_triplet *trp)
pstat = res->imports;
- uptr->fpr = xstrdup (pstat->fpr);
+ uptr->fpr = grecs_strdup (pstat->fpr);
if (debug_level > 2)
@@ -273,3 +273,4 @@ verify_directive_signature (struct file_triplet *trp)
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
@@ -207,3 +207,3 @@ schedule_job (const struct spool *spool, uid_t uid)
{
- job = xzalloc (sizeof (*job));
+ job = grecs_zalloc (sizeof (*job));
job->spool = spool;
diff --git a/src/lock.c b/src/lock.c
index 32367de..dece75d 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -189,3 +189,3 @@ host_name ()
size = 256;
- hostbuf = xmalloc (size);
+ hostbuf = grecs_malloc (size);
}
@@ -195,5 +195,5 @@ host_name ()
if (size < ns)
- xalloc_die ();
+ grecs_alloc_die ();
size = ns;
- hostbuf = xrealloc (hostbuf, size);
+ hostbuf = grecs_realloc (hostbuf, size);
}
@@ -263,3 +263,3 @@ fix_tagname (const char *tag)
{
- char *tagname = xstrdup (tag);
+ char *tagname = grecs_strdup (tag);
char *p;
@@ -280,3 +280,3 @@ wydawca_lockname (const char *tag)
if (!lockname)
- xalloc_die ();
+ grecs_alloc_die ();
free (tagname);
@@ -291,3 +291,3 @@ wydawca_lock_init ()
if (!lockdir)
- lockdir = xstrdup (LOCALSTATEDIR "/lock/" PACKAGE);
+ lockdir = grecs_strdup (LOCALSTATEDIR "/lock/" PACKAGE);
if (create_hierarchy (lockdir, 0))
diff --git a/src/mail.c b/src/mail.c
index bac0381..6855ed7 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -293,3 +293,3 @@ 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);
@@ -302,3 +302,3 @@ 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);
@@ -436,3 +436,3 @@ mail_stats ()
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);
@@ -446,3 +446,3 @@ mail_stats ()
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;
@@ -600,3 +600,3 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
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);
@@ -644,3 +644,3 @@ 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);
@@ -672,3 +672,3 @@ 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);
diff --git a/src/net.c b/src/net.c
index 3e9fe30..d08a6ba 100644
--- a/src/net.c
+++ b/src/net.c
@@ -105,3 +105,3 @@ handle_connection (FILE *in, FILE *out)
- if (getline (&buf, &buflen, in) <= 0)
+ if (grecs_getline (&buf, &buflen, in) <= 0)
return;
@@ -127,3 +127,3 @@ handle_connection (FILE *in, FILE *out)
- if (getline (&buf, &buflen, in) < 0)
+ if (grecs_getline (&buf, &buflen, in) < 0)
{
diff --git a/src/process.c b/src/process.c
index e41709d..200d987 100644
--- a/src/process.c
+++ b/src/process.c
@@ -29,3 +29,3 @@ register_spool (struct spool *spool)
{
- struct spool_list *sp = xmalloc (sizeof *sp);
+ struct spool_list *sp = grecs_malloc (sizeof *sp);
sp->spool = *spool;
@@ -115,3 +115,3 @@ parse_file_name (const char *name, struct file_info *finfo)
{
- finfo->name = xstrdup (name);
+ finfo->name = grecs_strdup (name);
finfo->type = suftab[i].type;
diff --git a/src/sql.c b/src/sql.c
index a4b311e..80eb344 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -32,3 +32,3 @@ sql_register_conn (struct sqlconn *conn)
{
- struct sql_list *ent = xmalloc (sizeof *ent);
+ struct sql_list *ent = grecs_malloc (sizeof *ent);
ent->conn = *conn;
@@ -200,3 +200,3 @@ sql_quote (struct dictionary *dict, void *handle, const char *input,
size = 2 * len + 1;
- output = xmalloc (size);
+ output = grecs_malloc (size);
mysql_real_escape_string (&conn->mysql, output, input, len);
diff --git a/src/timer.c b/src/timer.c
index 1634462..cece63a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -22,3 +22,2 @@
#include <ctype.h>
-#include <xalloc.h>
@@ -184,3 +183,3 @@ timer_format_time (double t)
if (!str)
- xalloc_die ();
+ grecs_alloc_die ();
return str;
@@ -212,3 +211,3 @@ _fill_meta (void *sym, void *data)
if (!buf) \
- xalloc_die (); \
+ grecs_alloc_die (); \
tp->def->kw = buf; \
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -62,2 +62,3 @@ hash_triplet_free (void *data)
struct uploader_info *next = up->next;
+ free (up->fpr);
free (up);
@@ -96,3 +97,3 @@ 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);
@@ -380,3 +381,3 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
if (grecs_asprintf (&sptr, &slen, "%lu", (unsigned long) info->sb.st_size))
- xalloc_die ();
+ grecs_alloc_die ();
@@ -393,3 +394,3 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
timebuf, info->name))
- xalloc_die ();
+ grecs_alloc_die ();
free (sptr);
@@ -413,3 +414,3 @@ expand_triplet_ls_full (struct metadef *def, void *data)
- def->value = def->storage = xmalloc (size + 1);
+ def->value = def->storage = grecs_malloc (size + 1);
def->value[0] = 0;
@@ -448,3 +449,3 @@ expand_triplet_ls_upload (struct metadef *def, void *data)
- def->value = def->storage = xmalloc (size + 1);
+ def->value = def->storage = grecs_malloc (size + 1);
def->value[0] = 0;
@@ -554,3 +555,3 @@ expand_email_user (struct metadef *def, void *data)
trp->uploader->realname, trp->uploader->email))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
@@ -596,3 +597,3 @@ expand_check_result (struct metadef *def, void *data)
"%d", WEXITSTATUS (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
@@ -604,3 +605,3 @@ expand_check_result (struct metadef *def, void *data)
WTERMSIG (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -36,4 +36,4 @@ 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;
@@ -91,3 +91,3 @@ txtacc_create ()
{
- struct txtacc *acc = xmalloc (sizeof (*acc));
+ struct txtacc *acc = grecs_malloc (sizeof (*acc));
acc->cur = grecs_list_create ();
@@ -139,2 +139,3 @@ txtacc_finish (struct txtacc *acc, int steal)
txtacc_entry_tailor (txtent);
+ grecs_list_append (acc->mem, txtent);
break;
@@ -160,5 +161,6 @@ txtacc_finish (struct txtacc *acc, int steal)
if (steal)
- free (txtent);
- else
- grecs_list_append (acc->mem, txtent);
+ {
+ grecs_list_remove_tail (acc->mem);
+ free (txtent);
+ }
return p;
@@ -175,3 +177,3 @@ txtacc_free_string (struct txtacc *acc, char *str)
{
- grecs_list_remove_entry(acc->mem, ep);
+ grecs_list_remove_entry (acc->mem, ep);
free (tp->buf);
diff --git a/src/verify.c b/src/verify.c
index a49983c..c8fef11 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -115,3 +115,3 @@ fill_project_name (struct file_triplet *trp)
- blurb = xmalloc (size + 1);
+ blurb = grecs_malloc (size + 1);
@@ -184,3 +184,3 @@ 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;
diff --git a/src/wydawca.c b/src/wydawca.c
index cc1815b..36aa8b7 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -73,3 +73,3 @@ syslog_printer (int prio, const char *fmt, va_list ap)
fmtsize = size;
- fmtbuf = x2realloc (fmtbuf, &fmtsize);
+ fmtbuf = grecs_realloc (fmtbuf, fmtsize);
}
@@ -181,3 +181,3 @@ stat_expand (struct metadef *def, void *data)
wydawca_stat[(int) def->data]))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
@@ -191,3 +191,3 @@ make_stat_expansion (size_t count)
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;
@@ -254,3 +254,3 @@ 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
@@ -43,2 +43,4 @@
#include <sysexits.h>
+#include <fnmatch.h>
+#include <regex.h>
@@ -48,5 +50,2 @@
-#include "error.h"
-#include "xalloc.h"
-#include "backupfile.h"
#include "grecs.h"
@@ -112,2 +111,17 @@ 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.