aboutsummaryrefslogtreecommitdiff
path: root/src/directive.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/directive.c')
-rw-r--r--src/directive.c34
1 files changed, 28 insertions, 6 deletions
diff --git a/src/directive.c b/src/directive.c
index 119b221..8893675 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -1,5 +1,5 @@
/* wydawca - automatic release submission daemon
- Copyright (C) 2007-2008, 2010-2011 Sergey Poznyakoff
+ Copyright (C) 2007-2008, 2010-2012 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
@@ -162,6 +162,13 @@ directive_pack_version (const char *val, unsigned *pversion)
return 0;
}
+int
+directive_unpack_version (unsigned version, char **pbuf, size_t *psize)
+{
+ return grecs_asprintf (pbuf, psize, "%u.%u",
+ version / 100, version % 100);
+}
+
/* Return true if the directory file version of the triplet TRP
is within the inclusive range FROM and TO (packed) */
int
@@ -177,14 +184,18 @@ directive_version_in_range_p (struct file_triplet *trp,
trp->file[file_directive].name);
return 0;
}
-
+
if (directive_pack_version (val, &version))
{
logmsg (LOG_ERR, _("%s: unparsable version: %s"),
trp->file[file_directive].name, val);
return 0;
}
-
+ logmsg (LOG_NOTICE, _("%s: VERSION: %s"),
+ trp->file[file_directive].name, val);
+
+ trp->version = version;
+
if (from <= version && version <= to)
return 1;
@@ -202,7 +213,8 @@ enum directive
filename_dir,
rmsymlink_dir,
archive_dir,
- symlink_dir
+ symlink_dir,
+ replace_dir
};
struct directive_table
@@ -219,6 +231,7 @@ static struct directive_table directive_table[] = {
{ "symlink", symlink_dir },
{ "rmsymlink", rmsymlink_dir },
{ "archive", archive_dir },
+ { "replace", replace_dir },
{ NULL }
};
@@ -240,8 +253,8 @@ verify_directive_format (struct file_triplet *trp)
int n, dnum;
const char *key;
- if (!directive_version_in_range_p (trp, MIN_DIRECTIVE_VERSION,
- MAX_DIRECTIVE_VERSION))
+ if (!directive_version_in_range_p (trp, min_directive_version,
+ max_directive_version))
return 1;
dnum = 0;
@@ -674,6 +687,15 @@ process_directives (struct file_triplet *trp)
case rmsymlink_dir:
if (rmsymlink_file (trp, val))
return 1;
+
+ case replace_dir:
+ if (trp->version < 102)
+ {
+ rc = 1;
+ logmsg (LOG_ERR,
+ _("\"replace\" directive is invalid for version %d"),
+ trp->version);
+ }
}
}

Return to:

Send suggestions and report system problems to the System administrator.