summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:21:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-13 07:33:34 (GMT)
commitde3fbe3e8d4dd2a89f7755906d76055784c437cc (patch) (side-by-side diff)
tree65356dd7b5a9010499550c468e960c93515a7e15
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 (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile.am4
-rwxr-xr-xbootstrap618
-rw-r--r--bootstrap.conf68
-rw-r--r--configure.ac5
-rw-r--r--gnulib.modules4
m---------grecs0
-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
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am14
-rw-r--r--tests/backup01.at33
-rw-r--r--tests/backup02.at43
-rw-r--r--tests/backup03.at41
-rw-r--r--tests/bkupname.c79
-rw-r--r--tests/testsuite.at4
34 files changed, 485 insertions, 779 deletions
diff --git a/Makefile.am b/Makefile.am
index a182931..29641e2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,27 +5,27 @@
# 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/>.
-ACLOCAL_AMFLAGS = -I m4 -I grecs/am
+ACLOCAL_AMFLAGS = -I grecs/am
-SUBDIRS=gnu grecs src doc etc tests
+SUBDIRS=grecs src doc etc tests
# We never remove files from the configuration directory
distuninstallcheck_listfiles = \
find $(prefix) -type f -not -path '$(sysconfdir)/*'
gen_start_date = 2009-01-25
.PHONY: ChangeLog
ChangeLog:
$(AM_V_GEN)if test -d .git; then \
git log --pretty='format:%ct %an <%ae>%n%n%s%n%n%b%n' | \
awk -f $(top_srcdir)/@GRECS_SUBDIR@/build-aux/git2chg.awk > ChangeLog; \
diff --git a/bootstrap b/bootstrap
index 760a095..ae677ac 100755
--- a/bootstrap
+++ b/bootstrap
@@ -1,615 +1,5 @@
#! /bin/sh
-
-# Bootstrap this package from checked-out sources.
-
-# Copyright (C) 2003-2008, 2009 Free Software Foundation, Inc.
-
-# Dico 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.
-
-# Dico 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 Dico. If not, see <http://www.gnu.org/licenses/>.
-
-# Written by Paul Eggert.
-
-nl='
-'
-
-# Ensure file names are sorted consistently across platforms.
-LC_ALL=C
-export LC_ALL
-
-local_gl_dir=gl
-
-# Temporary directory names.
-bt='._bootmp'
-bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
-bt2=${bt}2
-
-usage() {
- echo >&2 "\
-Usage: $0 [OPTION]...
-Bootstrap this package from the checked-out sources.
-
-Options:
- --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
- sources reside. Use this if you already
- have gnulib sources on your machine, and
- do not want to waste your bandwidth downloading
- them again.
- --copy Copy files instead of creating symbolic links.
- --force Attempt to bootstrap even if the sources seem
- not to have been checked out.
- --skip-po Do not download po files.
-
-If the file bootstrap.conf exists in the current working directory, its
-contents are read as shell variables to configure the bootstrap.
-
-Running without arguments will suffice in most cases.
-"
-}
-
-# Configuration.
-
-# Name of the Makefile.am
-gnulib_mk=gnulib.mk
-
-# List of gnulib modules needed.
-gnulib_modules=
-
-# Any gnulib files needed that are not in modules.
-gnulib_files=
-
-# The command to download all .po files for a specified domain into
-# a specified directory. Fill in the first %s is the domain name, and
-# the second with the destination directory. Use rsync's -L and -r
-# options because the latest/%s directory and the .po files within are
-# all symlinks.
-po_download_command_format=\
-"rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
-
-extract_package_name='
- /^AC_INIT(/{
- /.*,.*,.*, */{
- s///
- s/[][]//g
- s/)$//
- p
- q
- }
- s/AC_INIT(\[*//
- s/]*,.*//
- s/^GNU //
- y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
- s/[^A-Za-z0-9_]/-/g
- p
- }
-'
-package=`sed -n "$extract_package_name" configure.ac` || exit
-gnulib_name=lib$package
-
-build_aux=build-aux
-source_base=lib
-m4_base=m4
-doc_base=doc
-tests_base=tests
-
-# Extra files from gnulib, which override files from other sources.
-gnulib_extra_files="
- $build_aux/install-sh
- $build_aux/missing
- $build_aux/mdate-sh
- $build_aux/texinfo.tex
- $build_aux/depcomp
- $build_aux/config.guess
- $build_aux/config.sub
- doc/INSTALL
-"
-
-# Additional gnulib-tool options to use. Use "\newline" to break lines.
-gnulib_tool_option_extras=
-
-# Other locale categories that need message catalogs.
-EXTRA_LOCALE_CATEGORIES=
-
-# Additional xgettext options to use. Use "\\\newline" to break lines.
-XGETTEXT_OPTIONS='\\\
- --flag=_:1:pass-c-format\\\
- --flag=N_:1:pass-c-format\\\
- --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
-'
-
-# Package bug report address for gettext files
-MSGID_BUGS_ADDRESS=bug-$package@gnu.org
-
-# Files we don't want to import.
-excluded_files=
-
-# File that should exist in the top directory of a checked out hierarchy,
-# but not in a distribution tarball.
-checkout_only_file=README-hacking
-
-# Whether to use copies instead of symlinks.
-copy=false
-
-# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
-# those files to be generated in directories like lib/, m4/, and po/.
-# Or set it to 'auto' to make this script select which to use based
-# on which version control system (if any) is used in the source directory.
-vc_ignore=auto
-
-# Override the default configuration, if necessary.
-test -r bootstrap.conf && . ./bootstrap.conf
-
-if test "$vc_ignore" = auto; then
- vc_ignore=
- test -d .git && vc_ignore=.gitignore
- test -d CVS && vc_ignore="$vc_ignore .cvsignore"
-fi
-
-# Translate configuration into internal form.
-
-# Parse options.
-
-for option
-do
- case $option in
- --help)
- usage
- exit;;
- --gnulib-srcdir=*)
- GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
- --skip-po)
- SKIP_PO=t;;
- --force)
- checkout_only_file=;;
- --copy)
- copy=true;;
- *)
- echo >&2 "$0: $option: unknown option"
- exit 1;;
- esac
-done
-
-if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
- echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
- exit 1
-fi
-
-# If $STR is not already on a line by itself in $FILE, insert it,
-# sorting the new contents of the file and replacing $FILE with the result.
-insert_sorted_if_absent() {
- file=$1
- str=$2
- test -f $file || touch $file
- echo "$str" | sort -u - $file | cmp -s - $file \
- || echo "$str" | sort -u - $file -o $file \
- || exit 1
-}
-
-# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
-found_aux_dir=no
-grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
- >/dev/null && found_aux_dir=yes
-grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
- >/dev/null && found_aux_dir=yes
-if test $found_aux_dir = no; then
- echo "$0: expected line not found in configure.ac. Add the following:" >&2
- echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
- exit 1
-fi
-
-# If $build_aux doesn't exist, create it now, otherwise some bits
-# below will malfunction. If creating it, also mark it as ignored.
-if test ! -d $build_aux; then
- mkdir $build_aux
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- insert_sorted_if_absent $dot_ig $build_aux
- done
-fi
-
-echo "$0: Bootstrapping from checked-out $package sources..."
-
-cleanup_gnulib() {
- status=$?
- rm -fr gnulib
- exit $status
-}
-
-# Get gnulib files.
-
-case ${GNULIB_SRCDIR--} in
--)
- if [ ! -d gnulib ]; then
- echo "$0: getting gnulib files..."
-
- trap cleanup_gnulib 1 2 13 15
-
- git clone --depth 2 git://git.sv.gnu.org/gnulib ||
- cleanup_gnulib
-
- trap - 1 2 13 15
- fi
- GNULIB_SRCDIR=gnulib
-esac
-
-gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
-<$gnulib_tool || exit
-
-# Get translations.
-
-download_po_files() {
- subdir=$1
- domain=$2
- echo "$0: getting translations into $subdir for $domain..."
- cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
- eval "$cmd"
-}
-
-# Download .po files to $po_dir/.reference and copy only the new
-# or modified ones into $po_dir. Also update $po_dir/LINGUAS.
-update_po_files() {
- # Directory containing primary .po files.
- # Overwrite them only when we're sure a .po file is new.
- po_dir=$1
- domain=$2
-
- # Download *.po files into this dir.
- # Usually contains *.s1 checksum files.
- ref_po_dir="$po_dir/.reference"
-
- test -d $ref_po_dir || mkdir $ref_po_dir || return
- download_po_files $ref_po_dir $domain \
- && ls "$ref_po_dir"/*.po 2>/dev/null |
- sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
-
- langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
- test "$langs" = '*' && langs=x
- for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
- case $po in x) continue;; esac
- new_po="$ref_po_dir/$po.po"
- cksum_file="$ref_po_dir/$po.s1"
- if ! test -f "$cksum_file" ||
- ! test -f "$po_dir/$po.po" ||
- ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
- echo "updated $po_dir/$po.po..."
- cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
- fi
- done
-}
-
-case $SKIP_PO in
-'')
- if test -d po; then
- update_po_files po $package || exit
- fi
-
- if test -d runtime-po; then
- update_po_files runtime-po $package-runtime || exit
- fi;;
-esac
-
-symlink_to_dir()
-{
- src=$1/$2
- dst=${3-$2}
-
- test -f "$src" && {
-
- # If the destination directory doesn't exist, create it.
- # This is required at least for "lib/uniwidth/cjk.h".
- dst_dir=`dirname "$dst"`
- if ! test -d "$dst_dir"; then
- mkdir -p "$dst_dir"
-
- # If we've just created a directory like lib/uniwidth,
- # tell version control system(s) it's ignorable.
- # FIXME: for now, this does only one level
- parent=`dirname "$dst_dir"`
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$parent/$dot_ig
- insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
- done
- fi
-
- if $copy; then
- {
- test ! -h "$dst" || {
- echo "$0: rm -f $dst" &&
- rm -f "$dst"
- }
- } &&
- test -f "$dst" &&
- cmp -s "$src" "$dst" || {
- echo "$0: cp -fp $src $dst" &&
- cp -fp "$src" "$dst"
- }
- else
- test -h "$dst" &&
- src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
- dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
- test "$src_i" = "$dst_i" || {
- dot_dots=
- case $src in
- /*) ;;
- *)
- case /$dst/ in
- *//* | */../* | */./* | /*/*/*/*/*/)
- echo >&2 "$0: invalid symlink calculation: $src -> $dst"
- exit 1;;
- /*/*/*/*/) dot_dots=../../../;;
- /*/*/*/) dot_dots=../../;;
- /*/*/) dot_dots=../;;
- esac;;
- esac
-
- echo "$0: ln -fs $dot_dots$src $dst" &&
- ln -fs "$dot_dots$src" "$dst"
- }
- fi
- }
-}
-
-cp_mark_as_generated()
-{
- cp_src=$1
- cp_dst=$2
-
- if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
- symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
- elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
- symlink_to_dir $local_gl_dir "$cp_dst"
- else
- case $cp_dst in
- *.[ch]) c1='/* '; c2=' */';;
- *.texi) c1='@c '; c2= ;;
- *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
- *) c1= ; c2= ;;
- esac
-
- # If the destination directory doesn't exist, create it.
- # This is required at least for "lib/uniwidth/cjk.h".
- dst_dir=`dirname "$cp_dst"`
- test -d "$dst_dir" || mkdir -p "$dst_dir"
-
- if test -z "$c1"; then
- cmp -s "$cp_src" "$cp_dst" || {
- echo "$0: cp -f $cp_src $cp_dst" &&
- rm -f "$cp_dst" &&
- sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
- }
- else
- # Copy the file first to get proper permissions if it
- # doesn't already exist. Then overwrite the copy.
- cp "$cp_src" "$cp_dst-t" &&
- (
- echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
- echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
- sed "s!$bt_regex/!!g" "$cp_src"
- ) > $cp_dst-t &&
- if cmp -s "$cp_dst-t" "$cp_dst"; then
- rm -f "$cp_dst-t"
- else
- echo "$0: cp $cp_src $cp_dst # with edits" &&
- mv -f "$cp_dst-t" "$cp_dst"
- fi
- fi
- fi
-}
-
-version_controlled_file() {
- dir=$1
- file=$2
- found=no
- if test -d CVS; then
- grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
- grep '^/[^/]*/[0-9]' > /dev/null && found=yes
- elif test -d .git; then
- git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
- elif test -d .svn; then
- svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
- else
- echo "$0: no version control for $dir/$file?" >&2
- fi
- test $found = yes
-}
-
-slurp() {
- for dir in . `(cd $1 && find * -type d -print)`; do
- copied=
- sep=
- for file in `ls -a $1/$dir`; do
- case $file in
- .|..) continue;;
- .*) continue;; # FIXME: should all file names starting with "." be ignored?
- esac
- test -d $1/$dir/$file && continue
- for excluded_file in $excluded_files; do
- test "$dir/$file" = "$excluded_file" && continue 2
- done
- if test $file = Makefile.am; then
- copied=$copied${sep}$gnulib_mk; sep=$nl
- remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
- sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
- echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
- rm -f $dir/$gnulib_mk &&
- sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
- }
- elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
- version_controlled_file $dir $file; then
- echo "$0: $dir/$file overrides $1/$dir/$file"
- else
- copied=$copied$sep$file; sep=$nl
- if test $file = gettext.m4; then
- echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
- rm -f $dir/$file
- sed '
- /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
- AC_DEFUN([AM_INTL_SUBDIR], [
- /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
- AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
- $a\
- AC_DEFUN([gl_LOCK_EARLY], [])
- ' $1/$dir/$file >$dir/$file
- else
- cp_mark_as_generated $1/$dir/$file $dir/$file
- fi
- fi || exit
- done
-
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$dir/$dot_ig
- if test -n "$copied"; then
- insert_sorted_if_absent $ig "$copied"
- # If an ignored file name ends with .in.h, then also add
- # the name with just ".h". Many gnulib headers are generated,
- # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
- # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
- f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
- insert_sorted_if_absent $ig "$f"
-
- # For files like sys_stat.in.h and sys_time.in.h, record as
- # ignorable the directory we might eventually create: sys/.
- f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
- insert_sorted_if_absent $ig "$f"
- fi
- done
- done
-}
-
-
-# Create boot temporary directories to import from gnulib and gettext.
-rm -fr $bt $bt2 &&
-mkdir $bt $bt2 || exit
-
-# Import from gnulib.
-
-gnulib_tool_options="\
- --import\
- --no-changelog\
- --aux-dir $bt/$build_aux\
- --doc-base $bt/$doc_base\
- --lib $gnulib_name\
- --m4-base $bt/$m4_base/\
- --source-base $bt/$source_base/\
- --tests-base $bt/$tests_base\
- --local-dir $local_gl_dir\
- $gnulib_tool_option_extras\
-"
-echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
-$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
-slurp $bt || exit
-
-for file in $gnulib_files; do
- symlink_to_dir "$GNULIB_SRCDIR" $file || exit
-done
-
-
-# Import from gettext.
-with_gettext=yes
-grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
- with_gettext=no
-
-if test $with_gettext = yes; then
- echo "$0: (cd $bt2; autopoint) ..."
- cp configure.ac $bt2 &&
- (cd $bt2 && autopoint && rm configure.ac) &&
- slurp $bt2 $bt || exit
-
- rm -fr $bt $bt2 || exit
-fi
-
-# Coreutils is unusual in that it generates some of its test-related
-# Makefile.am files. That must be done before invoking automake.
-mam_template=tests/Makefile.am.in
-if test -f $mam_template; then
- PERL=perl
- for tool in cut head join pr sort tac tail test tr uniq wc; do
- m=tests/$tool/Makefile.am
- t=${m}t
- rm -f $m $t
- sed -n '1,/^##test-files-begin/p' $mam_template > $t
- echo "x = $tool" >> $t
- srcdir=tests/$tool
- $PERL -I$srcdir -w -- tests/mk-script $srcdir --list >> $t
- sed -n '/^##test-files-end/,$p' $mam_template >> $t
- chmod -w $t
- mv $t $m
- done
-fi
-
-# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
-# gnulib-populated directories. Such .m4 files would cause aclocal to fail.
-# The following requires GNU find 4.2.3 or newer. Considering the usual
-# portability constraints of this script, that may seem a very demanding
-# requirement, but it should be ok. Ignore any failure, which is fine,
-# since this is only a convenience to help developers avoid the relatively
-# unusual case in which a symlinked-to .m4 file is git-removed from gnulib
-# between successive runs of this script.
-find "$m4_base" "$source_base" \
- -depth \( -name '*.m4' -o -name '*.[ch]' \) \
- -type l -xtype l -delete > /dev/null 2>&1
-
-# Reconfigure, getting other files.
-
-echo "$0: autoreconf --force --install --symlink ..."
-autoreconf --force --install --symlink
-
-# FIXME: A kludge to avoid unnecessary data in the distribution.
-test -d libltdl/config && rm -rf libltdl/config
-test -d libltdl/m4 && rm -rf libltdl/m4
-
-# Get some extra files from gnulib, overriding existing files.
-for file in $gnulib_extra_files; do
- case $file in
- */INSTALL) dst=INSTALL;;
- build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
- *) dst=$file;;
- esac
- symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
-done
-
-if test $with_gettext = yes; then
- # Create gettext configuration.
- echo "$0: Creating po/Makevars from po/Makevars.template ..."
- rm -f po/Makevars
- sed '
- /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
- /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
- /^XGETTEXT_OPTIONS *=/{
- s/$/ \\/
- a\
- '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
- }
- ' po/Makevars.template >po/Makevars
-
- if test -d runtime-po; then
- # Similarly for runtime-po/Makevars, but not quite the same.
- rm -f runtime-po/Makevars
- sed '
- /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
- /^subdir *=.*/s/=.*/= runtime-po/
- /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
- /^XGETTEXT_OPTIONS *=/{
- s/$/ \\/
- a\
- '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
- }
- ' <po/Makevars.template >runtime-po/Makevars
-
- # Copy identical files from po to runtime-po.
- (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
- fi
-fi
-
-echo "$0: done. Now you can run './configure'."
+set -e
+git submodule init
+git submodule update
+autoreconf -f -i -s
diff --git a/bootstrap.conf b/bootstrap.conf
deleted file mode 100644
index 8464d0d..0000000
--- a/bootstrap.conf
+++ b/dev/null
@@ -1,68 +0,0 @@
-# Bootstrap configuration.
-
-# 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/>.
-
-source_base=gnu
-gnulib_name=libgnu
-gnulib_mk=Makefile.am
-
-test -d $source_base || mkdir -p $source_base
-
-git submodule init || exit $?
-git submodule update || exit $?
-
-# We don't need these modules, even though gnulib-tool mistakenly
-# includes them because of gettext dependencies.
-avoided_gnulib_modules='
- --avoid=lock
- --avoid=size_max
-'
-
-# gnulib modules used by this package.
-gnulib_modules="`grep -h '^[^#]' gnulib.modules | sort | uniq`"
-
-# Additional xgettext options to use. Use "\\\newline" to break lines.
-XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
- --flag=_:1:pass-c-format\\\
- --flag=N_:1:pass-c-format\\\
- --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
- --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format\\\
- --flag=gconf_warning:3:c-format\\\
- --flag=gconf_error:3:c-format\\\
-'
-
-# Gettext supplies these files, but we don't need them since
-# we don't have an intl subdirectory.
-excluded_files='
- m4/glibc2.m4
- m4/intdiv0.m4
- m4/lcmessage.m4
- m4/lock.m4
- m4/uintmax_t.m4
- m4/ulonglong.m4
- m4/visibility.m4
-'
-
-# Read local configuration file
-if [ -r .bootstrap ]; then
- echo "$0: Reading configuration file .bootstrap"
- eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
-fi
-
-test -f Changelog || cat > ChangeLog <<EOT
-This file is a placeholder. It will be replaced with the actual ChangeLog
-by make dist. Run make ChangeLog if you wish to create it earlier.
-EOT
diff --git a/configure.ac b/configure.ac
index 7002fb9..344c3b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,46 +17,42 @@
AC_PREREQ(2.63)
AC_INIT([wydawca], 2.1.90, [bug-wydawca@gnu.org.ua])
AC_CONFIG_SRCDIR([src/wydawca.c])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([1.11 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules])
# Enable silent rules by default:
AM_SILENT_RULES([yes])
# Checks for programs.
AC_PROG_CC
-gl_EARLY
-AC_PROG_LEX
-AC_PROG_YACC
AC_PROG_RANLIB
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIGNAL
AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_STDBOOL
# Checks for library functions.
-gl_INIT
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([fchdir memset strchr strdup strerror strrchr setegid setregid setresgid setresuid seteuid setreuid vsyslog sysconf getdtablesize])
# **********************
# Mailutils
# **********************
AM_GNU_MAILUTILS(2.0, [mailer], [:])
@@ -126,17 +122,16 @@ AH_BOTTOM([
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal tests/etc/Makefile])
AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_PATH_PROG(GPG, gpg, '')
if test -n "$GPG"; then
AC_SUBST(WYDAWCA_GPGFILES, '$(GPGFILES)')
fi
AC_CONFIG_FILES([Makefile
doc/Makefile
- gnu/Makefile
src/Makefile
etc/Makefile])
AC_OUTPUT
diff --git a/gnulib.modules b/gnulib.modules
deleted file mode 100644
index dd5124a..0000000
--- a/gnulib.modules
+++ b/dev/null
@@ -1,4 +0,0 @@
-xalloc
-getline
-mkdtemp
-backupfile
diff --git a/grecs b/grecs
-Subproject f8ca129aaf4876dfa9778c34ed5bd8a669ca22e
+Subproject 4c1056b45580fcb687cac656834f42dd9fba4ae
diff --git a/src/Makefile.am b/src/Makefile.am
index 8139849..3b524ba 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,24 +7,25 @@
# 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\
@@ -51,21 +52,21 @@ wydawca_SOURCES=\
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
--- a/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
@@ -7,26 +7,28 @@
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;
}
@@ -211,27 +213,27 @@ builtin_lookup (struct dictionary *dict, void *handle, const char *req)
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;
diff --git a/src/config.c b/src/config.c
index df9816e..8250749 100644
--- a/src/config.c
+++ b/src/config.c
@@ -137,25 +137,25 @@ safe_file_name (char *file_name)
{
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 },
@@ -540,70 +540,70 @@ cb_sql_host (enum grecs_callback_command cmd,
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:
@@ -887,25 +887,25 @@ static struct grecs_keyword notify_event_kw[] = {
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;
@@ -975,34 +975,34 @@ cb_dictionary_params (enum grecs_callback_command cmd,
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) },
@@ -1150,26 +1150,26 @@ cb_spool (enum grecs_callback_command cmd,
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)
{
@@ -1268,26 +1268,26 @@ cb_supp_groups (enum grecs_callback_command cmd,
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);
diff --git a/src/dictionary.c b/src/dictionary.c
index b7baf05..2b995d4 100644
--- a/src/dictionary.c
+++ b/src/dictionary.c
@@ -39,26 +39,25 @@ static struct dictionary_descr dictionary_tab[] = {
{ "sql", sql_init_dictionary, sql_done_dictionary, sql_free_result,
sql_open, NULL, sql_get_dictionary, sql_lookup_dictionary, sql_quote },
{ "builtin", builtin_init, builtin_done, builtin_free_result,
builtin_open, NULL,
builtin_get,
builtin_lookup },
{ "external", NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
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;
return mp;
}
int
dictionary_init (struct dictionary *dict)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
int rc = 0;
if (dict->init_passed++)
@@ -83,24 +82,26 @@ dictionary_open (struct dictionary *dict)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
if (!mp->open)
return NULL;
return mp->open (dict);
}
int
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;
return mp->close (dict, handle);
}
int
dictionary_done (struct dictionary *dict)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
int rc = 0;
if (dict->init_passed == 0)
@@ -177,52 +178,52 @@ dictionary_result (struct dictionary *dict, void *handle,
if (nrow >= dict->nrow || ncol >= dict->ncol
|| mp->get (dict, handle, nrow, ncol))
return NULL;
return dict->result;
}
void
dictionary_copy_result (struct dictionary *dict, const char *res, size_t size)
{
if (dict->result_size < size + 1)
{
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);
dict->result[size] = 0;
}
/* Quote non-printable characters in INPUT. Point *OUTPUT to the malloc'ed
quoted string. Return its length. */
int
dictionary_quote_string (struct dictionary *dict, void *handle,
const char *input,
char **poutput, size_t *psize)
{
struct dictionary_descr *mp = dictionary_tab + dict->type;
size_t size;
int quote;
char *output;
if (!input)
{
- *poutput = xmalloc (1);
+ *poutput = grecs_malloc (1);
(*poutput)[0] = 0;
*psize = 1;
return 0;
}
if (mp->quote)
return mp->quote (dict, handle, input, poutput, psize);
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;
*poutput = output;
if (psize)
*psize = size;
return 0;
}
diff --git a/src/directive.c b/src/directive.c
index 08a14df..fadaedf 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -25,25 +25,25 @@ directive_parse (struct file_triplet *trp)
size_t dcount, i, j;
char *p;
if (debug_level > 2)
logmsg (LOG_DEBUG, _("%s: parsing directive blurb: %s"),
trp->file[file_directive].name, trp->blurb);
dcount = 0;
for (p = trp->blurb; *p; p++)
if (*p == '\n')
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++)
{
trp->directive[j] = p;
p = strchr (p, '\n');
if (p)
*p++ = 0;
if (trim (trp->directive[j]) == 0) /* ignore empty lines */
continue;
if (strchr (trp->directive[j], ':') == NULL)
{
logmsg (LOG_ERR, _("%s: invalid line: %s"),
@@ -102,25 +102,25 @@ _directive_seq_get (int n, struct file_triplet *trp,
{
char *p;
size_t len;
if (trp->directive[n] == NULL)
return 0;
p = strchr (trp->directive[n], ':');
len = p - trp->directive[n];
if (len + 1 > trp->tmpsize)
{
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);
trp->tmp[len] = 0;
*pkey = trp->tmp;
for (p++; *p && isspace (*p); p++)
;
if (pval)
*pval = p;
return ++n;
}
/* Get the first directive from TRP. Point *PKEY to its keyword and
@@ -371,25 +371,25 @@ stderr_redirector (const char *tag)
}
if (pid == 0)
{
FILE *fp;
size_t size = 0;
char *buf = NULL;
close (p[1]);
fp = fdopen (p[0], "r");
if (!fp)
_exit (127);
- while (getline (&buf, &size, fp) >= 0)
+ while (grecs_getline (&buf, &size, fp) >= 0)
{
trim_crlf (buf);
logmsg (LOG_NOTICE, "%s: %s", tag, buf);
}
_exit (0);
}
close (p[0]);
return p[1];
}
static int
@@ -484,25 +484,25 @@ run_check_script (const char *script, struct file_triplet *trp,
execv ("/bin/sh", argv);
_exit (127);
}
/* Master */
free (script_file);
close (p[1]);
fp = fdopen (p[0], "r");
buf = NULL;
size = total = 0;
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);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("read: %s"), buf);
txtacc_grow (trp->acc, buf, len);
total += size;
}
txtacc_1grow (trp->acc, 0);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total);
fclose (fp);
diff --git a/src/diskio.c b/src/diskio.c
index 9addd9b..b175a45 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -37,25 +37,25 @@ sub_dir_p (const char *arg, const char *dir)
slash. */
char *
concat_dir (const char *base, const char *name, size_t *pbaselen)
{
size_t len = strlen (base);
size_t size;
char *dir;
while (len > 0 && base[len-1] == '/')
len--;
size = len + 1 + strlen (name);
- dir = xmalloc (size + 1);
+ dir = grecs_malloc (size + 1);
memcpy (dir, base, len);
dir[len++] = '/';
strcpy (dir + len, name);
if (pbaselen)
*pbaselen = len;
return dir;
}
/* Create the directory DIR, eventually creating all intermediate directories
starting from DIR + BASELEN. */
int
@@ -162,25 +162,25 @@ copy_file (const char *file, const char *dst_file)
file, strerror (errno));
close (in_fd);
return 1;
}
buf = NULL;
fsize = st.st_size;
for (bufsize = fsize; bufsize > 0 && (buf = malloc (bufsize)) == NULL;
bufsize /= 2)
;
if (bufsize == 0)
- xalloc_die ();
+ grecs_alloc_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"),
@@ -483,25 +483,25 @@ archive_single_file (struct file_triplet *trp, const char *file_name,
free (dst_dir);
return rc;
}
static char *
make_signame (const char *file_name)
{
size_t len;
if (((len = strlen (file_name)) > SUF_SIG_LEN
&& 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);
}
return NULL;
}
/* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the
file. Get user IDs from the triplet TRP. Unless FILE_NAME ends in
".sig", do the same with FILE_NAME.sig, if such a file exists.
Do nothing if dry_run_mode is set.
*/
int
diff --git a/src/exec.c b/src/exec.c
index ed7ee1e..7ebf152 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -66,25 +66,25 @@ start_prog (int argc, const char **argv, pid_t *ppid)
return fp;
}
/* Log everything read from FP as the output from the program PROG, using
syslog priority PRIO. */
void
log_output (int prio, const char *prog, FILE *fp)
{
size_t size = 0;
char *buf = NULL;
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);
free (buf);
}
/* Execute ARGC/ARGV. Return the exit code in RETCODE. */
enum exec_result
wydawca_exec (int argc, const char **argv, int *retcode)
{
FILE *fp;
pid_t pid, npid;
int status;
diff --git a/src/gpg.c b/src/gpg.c
index 474d94b..d4f9b71 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -123,25 +123,25 @@ remove_homedir ()
logmsg (LOG_DEBUG, _("removing GNUPG home directory: %s"), temp_homedir);
if (rmdir_r (temp_homedir))
logmsg (LOG_CRIT, _("failed to remove GPG directory %s"), temp_homedir);
}
/* Create a temporary GPG home directory */
static int
create_gpg_homedir ()
{
if (temp_homedir)
return 0;
- temp_homedir = xstrdup ("/tmp/wydawca-XXXXXX");
+ temp_homedir = grecs_strdup ("/tmp/wydawca-XXXXXX");
if (!mkdtemp (temp_homedir))
{
logmsg (LOG_CRIT, _("cannot create GPG home directory (%s): %s"),
temp_homedir, strerror (errno));
return 1;
}
atexit (remove_homedir);
if (debug_level > 1)
logmsg (LOG_DEBUG, _("GNUPG home directory: %s"), temp_homedir);
setenv ("GNUPGHOME", temp_homedir, 1);
return 0;
}
@@ -228,25 +228,25 @@ verify_directive_signature (struct file_triplet *trp)
for (uptr = trp->uploader_list; uptr; uptr = uptr->next)
{
gpgme_import_result_t res;
gpgme_import_status_t pstat;
fail_if_err (gpgme_data_new_from_mem (&key_data,
uptr->gpg_key,
strlen (uptr->gpg_key),
0));
fail_if_err (gpgme_op_import (ctx, key_data));
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"),
uptr->name, uptr->fpr);
}
fail_if_err (gpgme_data_new_from_file (&directive_data,
trp->file[file_directive].name, 1));
gpgme_data_new (&plain);
ec = gpgme_op_verify (ctx, directive_data, NULL, plain);
if (ec == GPG_ERR_NO_ERROR)
{
gpgme_verify_result_t result;
@@ -262,25 +262,26 @@ verify_directive_signature (struct file_triplet *trp)
rc = 0;
}
else
{
rc = 1;
UPDATE_STATS (STAT_BAD_SIGNATURE);
logmsg (LOG_ERR, _("%s: directive verification failed: %s"),
trp->name, gpgme_strerror (ec));
}
gpgme_data_release (directive_data);
gpgme_data_release (key_data);
-
+ gpgme_release (ctx);
+
return rc;
}
/* Verify the detached signature of TRP.
NOTE: It is assumed that the public key is already registered (by
a previous call to verify_directive_signature). */
int
verify_detached_signature (struct file_triplet *trp)
{
gpgme_engine_info_t info;
const char *argv[5];
const struct spool *spool;
diff --git a/src/job.c b/src/job.c
index 7e3fdf5..764e463 100644
--- a/src/job.c
+++ b/src/job.c
@@ -196,25 +196,25 @@ schedule_job (const struct spool *spool, uid_t uid)
struct job *job;
if (!spool)
spool = &fake_spool;
if (debug_level)
logmsg (LOG_DEBUG, _("scheduling job: %s, %lu"),
spool->tag, (unsigned long)uid);
job = job_locate (spool, uid);
if (!job)
{
- job = xzalloc (sizeof (*job));
+ job = grecs_zalloc (sizeof (*job));
job->spool = spool;
job->uid = uid;
job->pid = -1;
time (&job->timestamp);
job_insert (job, NULL);
}
job->state |= STATE_QUEUED;
job_start (job);
}
static void
diff --git a/src/lock.c b/src/lock.c
index 32367de..dece75d 100644
--- a/src/lock.c
+++ b/src/lock.c
@@ -178,33 +178,33 @@ host_name ()
static char *hostbuf = NULL;
size_t size = 0;
int rc;
if (hostbuf)
return hostbuf;
do
{
if (!hostbuf)
{
size = 256;
- hostbuf = xmalloc (size);
+ hostbuf = grecs_malloc (size);
}
else
{
size_t ns = size * 2;
if (size < ns)
- xalloc_die ();
+ grecs_alloc_die ();
size = ns;
- hostbuf = xrealloc (hostbuf, size);
+ hostbuf = grecs_realloc (hostbuf, size);
}
}
while ((rc = gethostname (hostbuf, size )) == -1 &&
(errno == EINVAL
#ifdef ENAMETOOLONG
|| errno == ENAMETOOLONG
#endif
));
if (rc)
{
logmsg (LOG_ERR, _("cannot get hostname: %s"), strerror (rc));
exit (EX_SOFTWARE);
@@ -252,45 +252,45 @@ wydawca_lock (const char *lockname)
}
void
wydawca_unlock (const char *lockfile)
{
if (enable_locking)
unlink (lockfile);
}
static char *
fix_tagname (const char *tag)
{
- char *tagname = xstrdup (tag);
+ char *tagname = grecs_strdup (tag);
char *p;
for (p = tagname; *p; p++)
if (!isalnum (*p) && *p != '_' && *p != '-')
*p = '_';
return tagname;
}
char *
wydawca_lockname (const char *tag)
{
char *lockname = NULL;
size_t size = 0;
char *tagname = fix_tagname (tag);
grecs_asprintf (&lockname, &size, "%s/LCK.%s", lockdir, tagname);
if (!lockname)
- xalloc_die ();
+ grecs_alloc_die ();
free (tagname);
return lockname;
}
void
wydawca_lock_init ()
{
if (enable_locking)
{
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
@@ -282,34 +282,34 @@ mail_send_message (mu_address_t rcpt, const char *text,
mu_stream_unref (stream);
if (rc)
{
logmsg (LOG_CRIT, _("cannot create message: %s"), mu_strerror (rc));
return;
}
mu_message_get_header (msg, &hdr);
mu_header_append (hdr, "X-Mailer", x_mailer);
if (rcpt)
{
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);
mu_header_set_value (hdr, "To", buf, 1);
free (buf);
if (from_address && mu_header_sget_value (hdr, "From", &sval))
{
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);
free (buf);
}
}
if (debug_level > 1)
{
mu_debug_level_t level;
mu_debug_get_category_level (MU_DEBCAT_MAILER, &level);
level |= MU_DEBUG_LEVEL_MASK (MU_DEBUG_TRACE0) |
@@ -425,35 +425,35 @@ mail_stats ()
if (!admin_address)
{
logmsg (LOG_ERR, _("cannot mail statistics: admin-address not defined"));
return;
}
if (debug_level)
{
size_t size;
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);
free (buf);
}
tc = timer_get_count () * 3;
exp = make_stat_expansion (tc + 1);
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);
tmpl = resolve_message_template (admin_stat_message);
if (!tmpl)
{
logmsg (LOG_ERR, _("undefined message reference: %s"),
admin_stat_message);
return;
}
text = meta_expand_string (tmpl, exp, NULL, NULL, NULL);
@@ -589,25 +589,25 @@ do_notify (struct file_triplet *trp, enum notification_event ev,
trp->project,
notification_event_str (ev), gettext (errp));
return;
}
if (debug_level)
{
if (rcpt)
{
size_t size;
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"),
buf, trp->project, notification_event_str (ev));
free (buf);
}
else
logmsg (LOG_DEBUG,
_("notifying message recipients (project %s) about %s"),
trp->project, notification_event_str (ev));
}
msg = resolve_message_template (ntf->msg);
@@ -633,25 +633,25 @@ notify (struct notification *notification_list,
if (p->ev == ev)
do_notify (trp, ev, p);
/* FIXME */
}
const char *
expand_email_admin (struct metadef *def, void *data)
{
size_t size;
if (mu_address_to_string (admin_address, NULL, 0, &size) == 0)
{
size++;
- def->storage = xmalloc (size);
+ def->storage = grecs_malloc (size);
mu_address_to_string (admin_address, def->storage, size, NULL);
def->value = def->storage;
}
else
def->value = "";
return def->value;
}
const char *
expand_email_owner (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
@@ -661,22 +661,22 @@ expand_email_owner (struct metadef *def, void *data)
addr = get_recipient (trp->spool->dictionary[project_owner_dict],
trp, &errp);
if (!addr)
{
logmsg (LOG_ERR, _("cannot get email of the %s's owner: %s"),
trp->project, gettext (errp));
def->value = "";
}
else if (mu_address_to_string (addr, NULL, 0, &size) == 0)
{
size++;
- def->storage = xmalloc (size);
+ def->storage = grecs_malloc (size);
mu_address_to_string (addr, def->storage, size, NULL);
def->value = def->storage;
mu_address_destroy (&addr);
}
else
def->value = "";
return def->value;
}
diff --git a/src/net.c b/src/net.c
index 3e9fe30..d08a6ba 100644
--- a/src/net.c
+++ b/src/net.c
@@ -94,47 +94,47 @@ trim_crlf (char *s)
}
}
void
handle_connection (FILE *in, FILE *out)
{
char *buf = NULL;
size_t buflen = 0;
const struct spool *spool;
char *p;
struct passwd *pw;
- if (getline (&buf, &buflen, in) <= 0)
+ if (grecs_getline (&buf, &buflen, in) <= 0)
return;
trim_crlf (buf);
if (debug_level)
logmsg (LOG_DEBUG, "recv: %s", buf);
spool = wydawca_find_spool (buf);
if (!spool)
{
if (all_spool_aliases && grecs_list_locate (all_spool_aliases, buf))
fprintf (out, "+ OK, all spools\r\n");
else
{
fprintf (out, "- Unknown service name\r\n");
free (buf);
return;
}
}
else if (spool->url)
fprintf (out, "+ OK, URL %s\r\n", spool->url);
else
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");
free (buf);
return;
}
trim_crlf (buf);
if (debug_level)
logmsg (LOG_DEBUG, "recv: %s", buf);
p = strchr (buf, ' ');
if (p)
diff --git a/src/process.c b/src/process.c
index e41709d..200d987 100644
--- a/src/process.c
+++ b/src/process.c
@@ -18,25 +18,25 @@
struct spool_list
{
struct spool_list *next;
struct spool spool;
};
static struct spool_list *spool_list;
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;
spool_list = sp;
}
static int
spool_check_alias (struct spool *spool, const char *name)
{
if (spool->aliases && grecs_list_locate (spool->aliases, (char*) name))
return 1;
return 0;
}
@@ -104,25 +104,25 @@ parse_file_name (const char *name, struct file_info *finfo)
{ SUF_DIR, SUF_DIR_LEN, file_directive },
{ "", 0, file_dist }
};
int i;
unsigned len = strlen (name);
for (i = 0; i < sizeof suftab / sizeof suftab[0]; i++)
{
if (len >= suftab[i].len
&& memcmp (name + len - suftab[i].len,
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;
return;
}
}
abort (); /* should not happen */
}
int
match_uid_p (uid_t uid, int uc, uid_t *uv)
{
int i;
diff --git a/src/sql.c b/src/sql.c
index a4b311e..80eb344 100644
--- a/src/sql.c
+++ b/src/sql.c
@@ -21,25 +21,25 @@
struct sql_list
{
struct sql_list *next;
struct sqlconn conn;
};
static struct sql_list *sql_list;
/* Append CONN to the end of sql_list */
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;
sql_list = ent;
}
/* Find a configured connection that has the given IDENT */
struct sqlconn *
sql_find_connection (const char *ident)
{
struct sql_list *p;
for (p = sql_list; p; p = p->next)
if (strcmp (p->conn.ident, ident) == 0)
@@ -189,19 +189,19 @@ sql_get_dictionary (struct dictionary *dict, void *handle,
}
int
sql_quote (struct dictionary *dict, void *handle, const char *input,
char **poutput, size_t *psize)
{
struct sqlconn *conn = handle;
size_t len, size;
char *output;
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;
if (psize)
*psize = strlen (output);
return 0;
}
diff --git a/src/timer.c b/src/timer.c
index 1634462..cece63a 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -11,25 +11,24 @@
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 <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
-#include <xalloc.h>
struct timer_slot
{
char *name;
double real;
double self_user; /* user time in sec */
double self_system; /* system time in sec */
double children_user; /* user time in sec */
double children_system; /* system time in sec */
struct timeval real_mark;
struct rusage self_mark;
struct rusage children_mark;
@@ -173,25 +172,25 @@ timer_format_time (double t)
s -= h * 3600;
m = s / 60;
s -= m * 60;
if (d)
grecs_asprintf (&str, &size, "%ld+%02ld:%02ld:%02ld", d, h, m, s);
else if (h)
grecs_asprintf (&str, &size, "%02ld:%02ld:%02ld", h, m, s);
else
grecs_asprintf (&str, &size, "%02ld:%02ld", m, s);
}
if (!str)
- xalloc_die ();
+ grecs_alloc_die ();
return str;
}
size_t
timer_get_count ()
{
return _timer_count;
}
struct timer_data
{
struct metadef *def;
@@ -201,25 +200,25 @@ struct timer_data
int
_fill_meta (void *sym, void *data)
{
struct timer_slot *slot = sym;
struct timer_data *tp = data;
#define CREATE_DEF(arg) \
if (tp->num) \
{ \
char *buf = NULL; \
size_t size = 0; \
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)); \
tp->def->value = tp->def->storage; \
tp->def->expand = NULL; \
tp->def++; \
tp->num--; \
}
CREATE_DEF(system);
CREATE_DEF(real);
CREATE_DEF(user);
diff --git a/src/triplet.c b/src/triplet.c
index 3083c64..9dfdf2c 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -51,24 +51,25 @@ hash_triplet_free (void *data)
free (tp->file[i].name);
}
free (tp->directive);
free (tp->blurb);
free (tp->tmp);
txtacc_free (tp->acc);
/* Free uploader list */
for (up = tp->uploader_list; up; )
{
struct uploader_info *next = up->next;
+ free (up->fpr);
free (up);
up = next;
}
free (tp);
}
char *
triplet_strdup (struct file_triplet *tp, const char *str)
{
size_t len = strlen (str);
txtacc_grow (tp->acc, str, len + 1);
@@ -85,25 +86,25 @@ register_file (struct file_info *finfo, const struct spool *spool)
if (!triplet_table)
{
triplet_table = grecs_symtab_create (sizeof (struct file_triplet),
hash_triplet_hasher,
hash_triplet_compare,
NULL,
NULL,
hash_triplet_free);
if (!triplet_table)
grecs_alloc_die ();
}
- 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;
ret = grecs_symtab_lookup_or_install (triplet_table, &key, &install);
if (!ret)
grecs_alloc_die ();
free (key.name);
if (install)
{
ret->spool = spool;
ret->acc = txtacc_create ();
}
@@ -369,58 +370,58 @@ format_file_data (struct file_triplet *trp, enum file_type type, char **pret)
user_name = "unknown";
else
user_name = pw->pw_name;
grp = getgrgid (TRIPLET_GID (trp));
if (!grp)
group_name = "unknown"; /* should not happen */
else
group_name = grp->gr_name;
/* 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 */
slen = strlen (sptr);
pad = strlen (user_name) + 1 + strlen (group_name) + 1 + slen;
if (pad > ugswidth)
ugswidth = pad;
if (grecs_asprintf (&buf, &size,
"%s %s %s %*s %s %s",
modes, user_name, group_name, ugswidth - pad + slen,
sptr,
timebuf, info->name))
- xalloc_die ();
+ grecs_alloc_die ();
free (sptr);
*pret = buf;
return 0;
}
static const char *
expand_triplet_ls_full (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
char *buf[FILE_TYPE_COUNT] = { NULL, NULL, NULL };
size_t size = 0;
if (format_file_data (trp, file_dist, &buf[file_dist]) == 0)
size += strlen (buf[file_dist]) + 1;
if (format_file_data (trp, file_signature, &buf[file_signature]) == 0)
size += strlen (buf[file_signature]) + 1;
if (format_file_data (trp, file_directive, &buf[file_directive]) == 0)
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])
{
strcat (def->value, buf[file_dist]);
strcat (def->value, "\n");
}
if (buf[file_signature])
{
strcat (def->value, buf[file_signature]);
strcat (def->value, "\n");
}
if (buf[file_directive])
@@ -437,25 +438,25 @@ expand_triplet_ls_full (struct metadef *def, void *data)
static const char *
expand_triplet_ls_upload (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
char *buf[2] = { NULL, NULL };
size_t size = 0;
if (format_file_data (trp, file_dist, &buf[file_dist]) == 0)
size += strlen (buf[file_dist]) + 1;
if (format_file_data (trp, file_signature, &buf[file_signature]) == 0)
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])
{
strcat (def->value, buf[file_dist]);
strcat (def->value, "\n");
}
if (buf[file_signature])
{
strcat (def->value, buf[file_signature]);
strcat (def->value, "\n");
}
@@ -543,25 +544,25 @@ expand_user_email (struct metadef *def, void *data)
return def->value;
}
static const char *
expand_email_user (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
if (trp->uploader)
{
size_t size = 0;
if (grecs_asprintf (&def->storage, &size, "\"%s\" <%s>",
trp->uploader->realname, trp->uploader->email))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
}
return def->value;
}
static const char *
expand_report (struct metadef *def, void *data)
{
return report_string;
}
static const char *
@@ -585,33 +586,33 @@ expand_check_result (struct metadef *def, void *data)
{
struct file_triplet *trp = data;
int status = trp->check_result;
if (status == 0)
return def->value = "0";
else if (WIFEXITED (status))
{
size_t size = 0;
def->storage = NULL;
if (grecs_asprintf (&def->storage, &size,
"%d", WEXITSTATUS (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
else if (WIFSIGNALED (status))
{
size_t size = 0;
def->storage = NULL;
if (grecs_asprintf (&def->storage, &size, "SIG+%d",
WTERMSIG (status)))
- xalloc_die ();
+ grecs_alloc_die ();
}
else
return def->value = "[unrecognized return code]";
return def->value = def->storage;
}
#define DECL_EXPAND_TIMER(what) \
static const char * \
__cat2__(expand_timer_,what) (struct metadef *def, void *data) \
{ \
wydawca_timer_t t = timer_stop ((char*)def->data); \
def->storage = timer_format_time (__cat2__(timer_get_,what) (t)); \
diff --git a/src/txtacc.c b/src/txtacc.c
index 91659f6..442e27e 100644
--- a/src/txtacc.c
+++ b/src/txtacc.c
@@ -25,26 +25,26 @@ struct txtacc_entry
#define TXTACC_BUFSIZE 1024
#define txtacc_entry_freesize(e) ((e)->size - (e)->len)
struct txtacc
{
struct grecs_list *cur; /* Current build list */
struct grecs_list *mem; /* List of already allocated elements */
};
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;
grecs_list_append (list, p);
return p;
}
static struct txtacc_entry *
txtacc_cur_entry (struct txtacc *acc)
{
struct txtacc_entry *ent;
if (grecs_list_size (acc->cur) == 0)
@@ -80,25 +80,25 @@ txtacc_entry_free (void *p)
{
if (p)
{
struct txtacc_entry *ent = p;
free (ent->buf);
free (ent);
}
}
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;
acc->mem = grecs_list_create ();
acc->mem->free_entry = txtacc_entry_free;
return acc;
}
void
txtacc_free (struct txtacc *acc)
{
grecs_list_free (acc->cur);
grecs_list_free (acc->mem);
@@ -128,55 +128,57 @@ txtacc_finish (struct txtacc *acc, int steal)
size_t size;
char *p;
switch (grecs_list_size (acc->cur))
{
case 0:
return NULL;
case 1:
txtent = acc->cur->head->data;
acc->cur->head->data = NULL;
txtacc_entry_tailor (txtent);
+ grecs_list_append (acc->mem, txtent);
break;
default:
size = 0;
for (ep = acc->cur->head; ep; ep = ep->next)
{
txtent = ep->data;
size += txtent->len;
}
txtent = txtacc_alloc_entry (acc->mem, size);
for (ep = acc->cur->head; ep; ep = ep->next)
{
struct txtacc_entry *tp = ep->data;
txtacc_entry_append (txtent, tp->buf, tp->len);
}
}
grecs_list_clear (acc->cur);
p = txtent->buf;
if (steal)
- free (txtent);
- else
- grecs_list_append (acc->mem, txtent);
+ {
+ grecs_list_remove_tail (acc->mem);
+ free (txtent);
+ }
return p;
}
void
txtacc_free_string (struct txtacc *acc, char *str)
{
struct grecs_list_entry *ep;
for (ep = acc->mem->head; ep; ep = ep->next)
{
struct txtacc_entry *tp = ep->data;
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
@@ -104,25 +104,25 @@ fill_project_name (struct file_triplet *trp)
trp->file[file_directive].name);
return 1;
}
fp = fopen (trp->file[file_directive].name, "r");
if (!fp)
{
logmsg (LOG_ERR, _("cannot open file %s: %s"),
trp->file[file_directive].name, strerror (errno));
return 1;
}
- blurb = xmalloc (size + 1);
+ blurb = grecs_malloc (size + 1);
rc = fread (blurb, size, 1, fp);
fclose (fp);
if (rc != 1)
{
logmsg (LOG_ERR, _("error reading file %s: %s"),
trp->file[file_directive].name, strerror (errno));
free (blurb);
return 1;
}
@@ -173,25 +173,25 @@ fill_project_name (struct file_triplet *trp)
txtacc_1grow (trp->acc, 0);
trp->project = txtacc_finish (trp->acc, 0);
}
else
trp->project = trp->relative_dir;
return 0;
}
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;
p->realname = src->realname;
p->gpg_key = src->gpg_key;
p->email = src->email;
p->fpr = NULL;
return p;
}
struct uploader_info *
uploader_find_frp (struct uploader_info *list, const char *fpr)
{
diff --git a/src/wydawca.c b/src/wydawca.c
index cc1815b..36aa8b7 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -62,25 +62,25 @@ void
syslog_printer (int prio, const char *fmt, va_list ap)
{
if (syslog_include_prio)
{
static char *fmtbuf;
static size_t fmtsize;
const char *p = mu_syslog_priority_to_string (prio);
size_t size = strlen (p) + 3 + strlen (fmt) + 1;
if (size > fmtsize)
{
fmtsize = size;
- fmtbuf = x2realloc (fmtbuf, &fmtsize);
+ fmtbuf = grecs_realloc (fmtbuf, fmtsize);
}
sprintf (fmtbuf, "[%s] %s", p, fmt);
fmt = fmtbuf;
}
#if HAVE_VSYSLOG
vsyslog (prio, fmt, ap);
#else
char buf[128];
vsnprintf (buf, sizeof buf, fmt, ap);
syslog (prio, "%s", buf);
#endif
@@ -170,35 +170,35 @@ stat_mask_p (unsigned long mask)
if (wydawca_stat[i] != 0 && (mask && STAT_MASK (i)))
return 1;
return 0;
}
static const char *
stat_expand (struct metadef *def, void *data)
{
size_t size = 0;
def->storage = NULL;
if (grecs_asprintf (&def->storage, &size, "%u",
wydawca_stat[(int) def->data]))
- xalloc_die ();
+ grecs_alloc_die ();
def->value = def->storage;
return def->value;
}
struct metadef *
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++)
{
p->kw = stat_kwname[i];
p->value = NULL;
p->storage = NULL;
p->expand = stat_expand;
p->data = (void*) i;
}
p->kw = NULL;
return def;
}
@@ -243,25 +243,25 @@ grecs_print_diag (grecs_locus_t *locus, int err, int errcode, const char *msg)
}
static int uidc;
static uid_t *uidv;
static void
collect_uids (int argc, char **argv)
{
int i;
uidc = argc;
- uidv = xcalloc (uidc, sizeof (uidv[0]));
+ uidv = grecs_calloc (uidc, sizeof (uidv[0]));
for (i = 0; i < argc; i++)
{
struct passwd *pw = getpwnam (argv[i]);
if (!pw)
{
char *p;
unsigned n = strtoul (argv[i], &p, 10);
if (*p)
{
logmsg (LOG_ERR, _("no such user: %s"), argv[i]);
exit (EX_NOUSER);
}
diff --git a/src/wydawca.h b/src/wydawca.h
index 2307bad..94b7ee3 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -32,32 +32,31 @@
#include <limits.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <time.h>
#include <sysexits.h>
+#include <fnmatch.h>
+#include <regex.h>
#include <mailutils/types.h>
#include <mailutils/url.h>
#include <mailutils/errno.h>
-#include "error.h"
-#include "xalloc.h"
-#include "backupfile.h"
#include "grecs.h"
#include "wordsplit.h"
#define SP(s) ((s) ? (s) : "NONE")
#define WYDAWCA_EX_AGAIN 1
/* The range of directive versions we accept (major * 100 + minor) */
#define MIN_DIRECTIVE_VERSION 101
#define MAX_DIRECTIVE_VERSION 101
/* Default modes for mkdir and creat commands: rely on the umask value */
@@ -101,24 +100,39 @@ struct dictionary
to use; */
int init_passed; /* Initialization count */
char *result; /* Result storage */
size_t result_size; /* Size of result */
unsigned ncol; /* Number of columns per row */
unsigned nrow; /* Number of rows */
void *storage;
};
+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 */
enum archive_type
{
archive_none, /* No archivation requested */
archive_directory, /* Archive by moving files to a separate directory
hierarchy */
archive_tar /* Archive by appending to a tar file (tar -r) */
};
struct archive_descr
{
diff --git a/tests/.gitignore b/tests/.gitignore
index 7c8bd6b..1df6b71 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,11 +1,12 @@
atconfig
atlocal
package.m4
testsuite
testsuite.dir
testsuite.log
source
dest
wstest
wsbatch
pushck
+bkupname
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b174fcd..cc52dbf 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -15,40 +15,44 @@
# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 dist
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
SUBDIRS = etc
## ------------ ##
## package.m4. ##
## ------------ ##
$(srcdir)/package.m4: $(top_srcdir)/configure.ac
- { \
+ $(AM_V_GEN){ \
echo '# Signature of the current package.'; \
echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
} >$(srcdir)/package.m4
#
## ------------ ##
## Test suite. ##
## ------------ ##
TESTSUITE_AT = \
+ backup00.at\
+ backup01.at\
+ backup02.at\
+ backup03.at\
check-fail.at\
check-notify.at\
check-ok.at\
notify-upl.at\
mailstats.at\
pushdir.at\
testsuite.at\
upload.at\
upload-dry.at\
version.at\
wordsplit.at
@@ -64,18 +68,20 @@ atconfig: $(top_builddir)/config.status
cd $(top_builddir) && ./config.status tests/$@
clean-local:
test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
check-local: atconfig atlocal $(TESTSUITE)
$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
#installcheck-local:
# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
-check_PROGRAMS = wstest wsbatch pushck
-INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/gnu -I../gnu -I$(top_srcdir)/src
-LDADD=../grecs/src/libgrecs.a ../gnu/libgnu.a
+check_PROGRAMS = wstest wsbatch pushck bkupname
+INCLUDES = -I$(top_srcdir)/grecs/src -I$(top_srcdir)/src
+LDADD=../grecs/src/libgrecs.a
pushck_LDADD=../src/pushd.o
+bkupname_LDADD=../src/backup.o ../grecs/src/libgrecs.a
+
diff --git a/tests/backup01.at b/tests/backup01.at
new file mode 100644
index 0000000..7cf4f93
--- a/dev/null
+++ b/tests/backup01.at
@@ -0,0 +1,33 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# 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, 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/>.
+
+AT_SETUP(simple backups)
+AT_KEYWORDS([backup backup01 simple_backups])
+
+AT_CHECK([bkupname -simple a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a
+bkupname -simple a
+],
+[0],
+[a~
+])
+
+AT_CLEANUP
diff --git a/tests/backup02.at b/tests/backup02.at
new file mode 100644
index 0000000..b5bcc54
--- a/dev/null
+++ b/tests/backup02.at
@@ -0,0 +1,43 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# 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, 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/>.
+
+AT_SETUP(numbered backups)
+AT_KEYWORDS([backup backup02 numbered_backups])
+
+AT_CHECK([bkupname -numbered a],
+[0],
+[a.~1~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -numbered a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -numbered a
+],
+[0],
+[a.~100~
+])
+
+
+
+AT_CLEANUP
diff --git a/tests/backup03.at b/tests/backup03.at
new file mode 100644
index 0000000..947c145
--- a/dev/null
+++ b/tests/backup03.at
@@ -0,0 +1,41 @@
+# This file is part of wydawca testsuite -*- Autotest -*-
+# 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, 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/>.
+
+AT_SETUP(numbered existing backups)
+AT_KEYWORDS([backup backup03 numbered_existing_backups])
+
+AT_CHECK([bkupname -existing a],
+[0],
+[a~
+])
+
+AT_CHECK([
+touch a.~1~
+bkupname -existing a
+],
+[0],
+[a.~2~
+])
+
+AT_CHECK([
+touch a.~99~
+bkupname -existing a
+],
+[0],
+[a.~100~
+])
+
+AT_CLEANUP
diff --git a/tests/bkupname.c b/tests/bkupname.c
new file mode 100644
index 0000000..6187146
--- a/dev/null
+++ b/tests/bkupname.c
@@ -0,0 +1,79 @@
+/* wordsplit - a word splitter
+ Copyright (C) 2009, 2010 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
+ Free Software Foundation; either version 3 of the License, or (at your
+ option) any later version.
+
+ This program 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include "wydawca.h"
+
+char *progname;
+
+void
+usage (int code)
+{
+ FILE *fp = code ? stderr : stdout;
+
+ fprintf (fp, "usage: %s [-no] [-simple] [-existing] [-numbered] [-suffix=S] FILE\n",
+ progname);
+ exit (code);
+}
+
+int
+main (int argc, char **argv)
+{
+ enum backup_type type = numbered_backups;
+ char *file = NULL;
+ char *backup;
+
+ progname = argv[0];
+ while (--argc)
+ {
+ char *arg = *++argv;
+ if (strcmp (arg, "-no") == 0)
+ type = no_backups;
+ else if (strcmp (arg, "-simple") == 0)
+ type = simple_backups;
+ else if (strcmp (arg, "-existing") == 0)
+ type = numbered_existing_backups;
+ else if (strcmp (arg, "-numbered") == 0)
+ type = numbered_backups;
+ else if (strncmp (arg, "-suffix=", 8) == 0)
+ simple_backup_suffix = arg + 8;
+ else if (arg[0] == '-')
+ usage (2);
+ else
+ {
+ if (argc != 1)
+ usage (2);
+ file = arg;
+ }
+ }
+
+ if (!file)
+ usage (2);
+ backup = find_backup_file_name (file, type);
+ if (!backup)
+ {
+ if (errno)
+ {
+ perror (file);
+ exit (1);
+ }
+ printf ("no backup\n");
+ }
+ else
+ printf ("%s\n", backup);
+ free (backup);
+ exit (0);
+}
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 240ab5d..2318762 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -15,21 +15,25 @@
# You should have received a copy of the GNU General Public License
# along with Wydawca. If not, see <http://www.gnu.org/licenses/>.
m4_version_prereq([2.52g])
m4_define([AT_SKIP_TEST],[exit 77])
AT_INIT
AT_TESTED([wydawca])
m4_include([version.at])
m4_include([wordsplit.at])
m4_include([pushdir.at])
+m4_include([backup00.at])
+m4_include([backup01.at])
+m4_include([backup02.at])
+m4_include([backup03.at])
m4_include([upload-dry.at])
m4_include([upload.at])
m4_include([notify-upl.at])
m4_include([mailstats.at])
m4_include([check-fail.at])
m4_include([check-ok.at])
m4_include([check-notify.at])

Return to:

Send suggestions and report system problems to the System administrator.