aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2010-01-03 19:40:33 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2010-01-03 20:03:27 +0200
commitfa78a9f21ff4fd85fb568232c9bee957b9c83497 (patch)
tree597162dff26a81877b5788fc5015fc8b075354b7
parent17f28552af10e72a221a0be16417249852774f1b (diff)
downloadwydawca-fa78a9f21ff4fd85fb568232c9bee957b9c83497.tar.gz
wydawca-fa78a9f21ff4fd85fb568232c9bee957b9c83497.tar.bz2
Improve memory management and optimize function signatures.
* src/wydawca.h (file_triplet): New members: relative_dir, obstk. (virt_tab): Remove spool and reldir from argument lists. (triplet_strdup): New prototype. (move_file, archive_file, symlink_file) (rmsymlink_file, dir_move_file, dir_archive_file) (dir_symlink_file, dir_rmsymlink_file) (null_move_file, null_archive_file) (null_symlink_file, null_rmsymlink_file): Remove spool and reldir from argument lists. * src/directive.c (run_check_script): Use trp->obstk to store the program output. (process_directives): Update calls to vtab interfaces. * src/diskio.c (dir_move_file) (dir_archive_file, dir_symlink_file) (dir_rmsymlink_file): Remove spool and reldir arguments. Use the corresponding members of the struct file_triplet. * src/null.c (null_move_file, null_archive_file) (null_symlink_file, null_rmsymlink_file): Likewise. * src/vtab.c (move_file, archive_file) (symlink_file, rmsymlink_file): Likewise. * src/triplet.c (hash_triplet_free): Free obstack and uploader_list. (triplet_strdup): New function. (register_file): Initialize trp->obstck. (fill_project_name): Fill relative_dir as well. (verify_directive_file): Use triplet_strdup to keep string values.
-rw-r--r--src/directive.c34
-rw-r--r--src/diskio.c61
-rw-r--r--src/null.c22
-rw-r--r--src/triplet.c24
-rw-r--r--src/verify.c38
-rw-r--r--src/vtab.c29
-rw-r--r--src/wydawca.h56
7 files changed, 126 insertions, 138 deletions
diff --git a/src/directive.c b/src/directive.c
index 93830b1..34e5feb 100644
--- a/src/directive.c
+++ b/src/directive.c
@@ -401,13 +401,12 @@ run_check_script (const char *script, struct file_triplet *trp,
int status;
int p[2];
RETSIGTYPE (*oldsig)();
FILE *fp;
char *buf;
size_t size, total;
- struct obstack stk;
if (debug_level > 1)
logmsg (LOG_DEBUG, _("prep script: %20.20s%s"),
script, strlen (script) > 20 ? "..." : "");
script_file = save_script (script);
if (!script_file)
@@ -489,35 +488,33 @@ run_check_script (const char *script, struct file_triplet *trp,
/* Master */
free (script_file);
close (p[1]);
fp = fdopen (p[0], "r");
buf = NULL;
size = total = 0;
- obstack_init (&stk);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("reading script output..."));
while (getline (&buf, &size, fp) > 0)
{
size_t len = strlen (buf);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("read: %s"), buf);
- obstack_grow (&stk, buf, len);
+ obstack_grow (&trp->obstk, buf, len);
total += size;
}
- obstack_1grow (&stk, 0);
+ obstack_1grow (&trp->obstk, 0);
if (debug_level > 2)
logmsg (LOG_DEBUG, _("bytes read: %lu"), (unsigned long)total);
fclose (fp);
waitpid (pid, &status, 0);
signal (SIGCHLD, oldsig);
if (total)
- trp->check_diag = xstrdup (obstack_finish (&stk));
- obstack_free (&stk, NULL);
+ trp->check_diag = obstack_finish (&trp->obstk);
trp->check_result = status;
if (WIFEXITED (status))
{
status = WEXITSTATUS (status);
if (status)
@@ -590,13 +587,12 @@ external_check (struct file_triplet *trp)
/* Process the directives from TRP */
int
process_directives (struct file_triplet *trp)
{
int rc, n;
const char *key, *val;
- char *relative_dir;
const struct spool *spool;
ASGN_SPOOL (spool, trp, return 1);
UPDATE_STATS (STAT_COMPLETE_TRIPLETS);
timer_start ("triplet");
report_init ();
@@ -613,46 +609,40 @@ process_directives (struct file_triplet *trp)
case comment_dir:
logmsg (LOG_NOTICE, _("%s: COMMENT: %s"),
trp->file[file_directive].name, val);
break;
case directory_dir:
- /* FIXME: Alloc it in triplet */
- relative_dir = safe_file_name_alloc (val);
- if (!relative_dir || relative_dir[0] == '/')
- {
- logmsg (LOG_ERR, _("%s: invalid directory: %s"),
- trp->file[file_directive].name, val);
- return 1;
- }
+ /* already processed (see fill_project_name in verify.c */
break;
case filename_dir:
rc = verify_detached_signature (trp);
if (rc == 0)
{
if (external_check (trp))
return 1;
- if (move_file (trp, spool, file_dist, relative_dir)
- || move_file (trp, spool, file_signature, relative_dir))
+ if (move_file (trp, file_dist)
+ || move_file (trp, file_signature))
return 1;
}
else
{
logmsg (LOG_ERR, _("invalid detached signature for %s"),
trp->name);
return 1;
}
break;
case version_dir:
- /* Already processed */
+ /* Already processed. See directive_version_in_range_p,
+ called by verify_directive_format */
break;
case archive_dir:
- if (archive_file (trp, spool, relative_dir, val))
+ if (archive_file (trp, val))
return 1;
break;
case symlink_dir:
{
int rc = 0;
@@ -670,34 +660,32 @@ process_directives (struct file_triplet *trp)
rc = 1;
logmsg (LOG_ERR,
_("wrong number of arguments to %s directive: `%s'"),
key, val);
}
else
- rc = symlink_file (trp, spool, relative_dir,
- ws.ws_wordv[0], ws.ws_wordv[1]);
+ rc = symlink_file (trp, ws.ws_wordv[0], ws.ws_wordv[1]);
wordsplit_free (&ws);
if (rc)
return 1;
}
break;
case rmsymlink_dir:
- if (rmsymlink_file (trp, spool, relative_dir, val))
+ if (rmsymlink_file (trp, val))
return 1;
}
}
if (!dry_run_mode && unlink (trp->file[file_directive].name))
{
logmsg (LOG_CRIT, _("%s: cannot unlink directive file: %s"),
trp->file[file_directive].name, strerror (errno));
}
- free (relative_dir);
UPDATE_STATS (STAT_TRIPLET_SUCCESS);
report_finish ();
timer_stop ("triplet");
notify (spool->notification, trp, ev_success);
return 0;
}
diff --git a/src/diskio.c b/src/diskio.c
index 1760a88..46526d0 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -105,13 +105,13 @@ create_hierarchy (char *dir, size_t baselen)
}
}
return rc;
}
/* Create a directory BASE/NAME (with eventual intermediate directories in
- NAME). Use UID and GID as owner ids.
+ NAME).
Do nothing if dry_run_mode is set. */
char *
create_directory (const char *base, const char *name)
{
size_t baselen;
char *dir = concat_dir (base, name, &baselen);
@@ -369,57 +369,65 @@ backup_file (const char *dst_file, const char *dst_dir, const char *file,
for the argument description. */
int
do_archive_file (const char *dst_file, const char *dst_dir, const char *file,
const struct archive_descr *archive,
const char *reldir)
{
+ int rc = 0;
+
switch (archive->type)
{
case archive_none:
break;
case archive_directory:
- return backup_file (dst_file, dst_dir, file, archive, reldir);
+ if (backup_file (dst_file, dst_dir, file, archive, reldir))
+ return 1;
+ UPDATE_STATS (STAT_ARCHIVES);
+ break;
case archive_tar:
if (tar_append_file (archive->name, dst_file))
return 1;
+ UPDATE_STATS (STAT_ARCHIVES);
+ break;
}
- if (!dry_run_mode && unlink (dst_file))
+
+ if (!dry_run_mode && unlink (dst_file) && errno != ENOENT)
{
logmsg (LOG_ERR, _("canot unlink file `%s': %s"),
dst_file, strerror (errno));
return 1;
}
return 0;
}
/* Move the part FILE_ID of the triplet TRP between the directories in
- DPAIR. RELDIR gives relative directory (i.e. the directory part of
- the file name) for backup purposes.
+ TRP->SPOOL. TRP->RELATIVE_DIR gives relative directory (i.e. the
+ directory part of the file name) for backup purposes.
Do nothing if dry_run_mode is set. */
int
-dir_move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir)
+dir_move_file (struct file_triplet *trp, enum file_type file_id)
{
char *dst_file;
int rc = 0;
- char *dst_dir = create_directory (spool->dest_dir, reldir);
+ const struct spool *spool = trp->spool;
+ char *dst_dir = create_directory (spool->dest_dir, trp->relative_dir);
if (!dst_dir)
return 1;
dst_file = concat_dir (dst_dir, trp->file[file_id].name, NULL);
if (debug_level)
logmsg (LOG_DEBUG, _("installing %s to %s"), trp->file[file_id].name,
dst_dir);
if (access (dst_file, F_OK) == 0)
rc = do_archive_file (dst_file, dst_dir, trp->file[file_id].name,
- &spool->archive, reldir);
+ &spool->archive, trp->relative_dir);
if (!dry_run_mode && rc == 0)
rc = do_move_file (trp->file[file_id].name, dst_file);
free (dst_file);
free (dst_dir);
@@ -430,19 +438,19 @@ dir_move_file (struct file_triplet *trp, const struct spool *spool,
/* Archive the file FILE_NAME, located in DPAIR->dest_dir, and remove the
file. Get user IDs from the triplet TRP.
Do nothing if dry_run_mode is set.
*/
int
-archive_single_file (struct file_triplet *trp, const struct spool *spool,
- const char *file_name, const char *reldir,
+archive_single_file (struct file_triplet *trp, const char *file_name,
int noentok)
{
char *dst_file;
int rc = 0;
- char *dst_dir = create_directory (spool->dest_dir, reldir);
+ const struct spool *spool = trp->spool;
+ char *dst_dir = create_directory (spool->dest_dir, trp->relative_dir);
if (!dst_dir)
return 1;
dst_file = safe_file_name (concat_dir (dst_dir, file_name, NULL));
if (!sub_dir_p (dst_file, spool->dest_dir))
@@ -456,15 +464,13 @@ archive_single_file (struct file_triplet *trp, const struct spool *spool,
if (access (dst_file, F_OK) == 0)
{
if (debug_level)
logmsg (LOG_DEBUG, _("archiving file `%s'"), dst_file);
rc = do_archive_file (dst_file, dst_dir, file_name, &spool->archive,
- reldir);
- if (rc == 0)
- UPDATE_STATS (STAT_ARCHIVES);
+ trp->relative_dir);
}
else if (errno == ENOENT)
{
if (!noentok)
logmsg (LOG_NOTICE, _("nothing to archive: file `%s' does not exist"),
dst_file);
@@ -499,39 +505,38 @@ make_signame (const char *file_name)
/* 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
-dir_archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name)
+dir_archive_file (struct file_triplet *trp, const char *file_name)
{
int rc;
char *signame;
- rc = archive_single_file (trp, spool, file_name, reldir, 0);
+ rc = archive_single_file (trp, file_name, 0);
if (rc == 0 && archive_signatures && (signame = make_signame (file_name)))
{
- rc = archive_single_file (trp, spool, signame, reldir, 1);
+ rc = archive_single_file (trp, signame, 1);
free (signame);
}
return rc;
}
/* Create a symbolic link from WANTED_SRC to WANTED_DST in the subdirectory
- RELDIR of DPAIR->dest_dir. Get ownership information from TRP.
+ TRP->relative_dir of SPOOL->dest_dir.
Do nothing if dry_run_mode is set. */
int
-dir_symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+dir_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
int rc = 0;
struct saved_cwd cwd;
- char *dst_dir = create_directory (spool->dest_dir, reldir);
+ const struct spool *spool = trp->spool;
+ char *dst_dir = create_directory (spool->dest_dir, trp->relative_dir);
char *src, *dst;
if (!dst_dir)
return 1;
if (save_cwd (&cwd))
@@ -671,25 +676,23 @@ do_rmsymlink_file (const char *dst_file, int noentok)
return 1;
}
UPDATE_STATS (STAT_RMSYMLINKS);
return 0;
}
-/* Remove the symbolic link DPAIR->dest_dir/RELDIR/FILE_NAME
-
- Get ownership information from TRP.
+/* Remove the symbolic link TRP->spool->dest_dir/TRP->relative_dir/FILE_NAME
Do nothing if dry_run_mode is set. */
int
-dir_rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name)
+dir_rmsymlink_file (struct file_triplet *trp, const char *file_name)
{
char *dst_file;
int rc = 0;
char *signame;
- char *dst_dir = create_directory (spool->dest_dir, reldir);
+ const struct spool *spool = trp->spool;
+ char *dst_dir = create_directory (spool->dest_dir, trp->relative_dir);
if (!dst_dir)
return 1;
dst_file = safe_file_name (concat_dir (dst_dir, file_name, NULL));
if (!sub_dir_p (dst_file, spool->dest_dir))
diff --git a/src/null.c b/src/null.c
index 4a443e3..c37ade3 100644
--- a/src/null.c
+++ b/src/null.c
@@ -14,56 +14,54 @@
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"
int
-null_move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir)
+null_move_file (struct file_triplet *trp, enum file_type file_id)
{
+ const struct spool *spool = trp->spool;
const char *file_name = trp->file[file_id].name;
if (debug_level)
logmsg (LOG_DEBUG, _("spool %s: installing file `%s/%s'"),
- spool->tag, reldir, file_name);
+ spool->tag, trp->relative_dir, file_name);
UPDATE_STATS (STAT_UPLOADS);
if (!dry_run_mode && unlink (file_name))
{
logmsg (LOG_ERR, _("cannot unlink %s: %s"),
file_name, strerror (errno));
return 1;
}
return 0;
}
int
-null_archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *file_name, const char *reldir)
+null_archive_file (struct file_triplet *trp, const char *file_name)
{
if (debug_level)
- logmsg (LOG_DEBUG, _("spool %s: archiving `%s'"), spool->tag, file_name);
+ logmsg (LOG_DEBUG, _("spool %s: archiving `%s'"),
+ trp->spool->tag, file_name);
UPDATE_STATS (STAT_ARCHIVES);
return 0;
}
int
-null_symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+null_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
if (debug_level)
logmsg (LOG_DEBUG, _("spool %s: symlinking `%s' to `%s'"),
- spool->tag, wanted_src, wanted_dst);
+ trp->spool->tag, wanted_src, wanted_dst);
UPDATE_STATS (STAT_SYMLINKS);
return 0;
}
int
-null_rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name)
+null_rmsymlink_file (struct file_triplet *trp, const char *file_name)
{
if (debug_level)
logmsg (LOG_DEBUG, _("spool %s: removing symlink `%s/%s'"),
- spool->tag, reldir, file_name);
+ trp->spool->tag, trp->relative_dir, file_name);
UPDATE_STATS (STAT_RMSYMLINKS);
return 0;
}
diff --git a/src/triplet.c b/src/triplet.c
index efe4a0b..ea57a08 100644
--- a/src/triplet.c
+++ b/src/triplet.c
@@ -39,28 +39,44 @@ hash_triplet_compare (void const *data1, void const *data2)
/* Reclaim memory storage associated with a table entry */
void
hash_triplet_free (void *data)
{
int i;
struct file_triplet *tp = data;
+ struct uploader_info *up;
for (i = 0; i < FILE_TYPE_COUNT; i++)
{
if (tp->file[i].name)
free (tp->file[i].name);
}
free (tp->directive);
free (tp->blurb);
free (tp->tmp);
- free (tp->check_diag);
- /* FIXME: free uploader list */
+ obstack_free (&tp->obstk, NULL);
+
+ /* Free uploader list */
+ for (up = tp->uploader_list; up; )
+ {
+ struct uploader_info *next = up->next;
+ free (up);
+ up = next;
+ }
free (tp);
}
+char *
+triplet_strdup (struct file_triplet *tp, const char *str)
+{
+ size_t len = strlen (str);
+ obstack_grow (&tp->obstk, str, len + 1);
+ return obstack_finish (&tp->obstk);
+}
+
/* Register a file in the triplet table */
void
register_file (struct file_info *finfo, const struct spool *spool)
{
struct file_triplet *tp, *ret;
@@ -76,13 +92,15 @@ register_file (struct file_info *finfo, const struct spool *spool)
hash_triplet_hasher,
hash_triplet_compare,
hash_triplet_free)))
&& (ret = hash_insert (triplet_table, tp))))
xalloc_die ();
- if (ret != tp)
+ if (ret == tp)
+ obstack_init (&tp->obstk);
+ else
free (tp);
ret->file[finfo->type] = *finfo;
}
/* Return true if any part of the triplet TRP was modified more than
TTL seconds ago */
diff --git a/src/verify.c b/src/verify.c
index 01c61ea..93fd28b 100644
--- a/src/verify.c
+++ b/src/verify.c
@@ -90,13 +90,13 @@ extract_plaintext (char *blurb)
int
fill_project_name (struct file_triplet *trp)
{
char *blurb;
size_t size;
FILE *fp;
- char *project, *p;
+ char *p;
const char *directory;
int rc;
size = trp->file[file_directive].sb.st_size;
if (size <= MSG_BEGIN_MARKER_LEN)
{
@@ -147,29 +147,38 @@ fill_project_name (struct file_triplet *trp)
if (directive_get_value (trp, "directory", &directory))
{
logmsg (LOG_ERR, _("%s: missing `directory' directive"),
trp->file[file_directive].name);
return 1;
}
- p = strchr (directory, '/');
+
+ trp->relative_dir = safe_file_name (triplet_strdup (trp, directory));
+ if (!trp->relative_dir || trp->relative_dir[0] == '/')
+ {
+ logmsg (LOG_ERR, _("%s: invalid directory: %s"),
+ trp->file[file_directive].name, directory);
+ return 1;
+ }
+
+ p = strchr (trp->relative_dir, '/');
if (p)
{
- size_t len = p - directory;
+ size_t len = p - trp->relative_dir;
if (len == 0)
{
logmsg (LOG_ERR, _("%s: empty `directory' directive"),
trp->file[file_directive].name);
return 1;
}
- project = xmalloc (len + 1);
- memcpy (project, directory, len);
- project[len] = 0;
+ obstack_grow (&trp->obstk, trp->relative_dir, len);
+ obstack_1grow (&trp->obstk, 0);
+ trp->project = obstack_finish (&trp->obstk);
}
else
- project = xstrdup (directory);
- trp->project = xstrdup (project);
+ trp->project = trp->relative_dir;
+
return 0;
}
struct uploader_info *
new_uploader_info (struct uploader_info *src)
{
@@ -251,22 +260,22 @@ verify_directive_file (struct file_triplet *trp)
const char *p;
struct uploader_info info, *ptr;
memset (&info, 0, sizeof (info));
p = dictionary_result (dict, md, i, 0);
if (p)
- info.name = xstrdup (p);
+ info.name = triplet_strdup (trp, p);
p = dictionary_result (dict, md, i, 1);
if (p)
- info.realname = xstrdup (p);
+ info.realname = triplet_strdup (trp, p);
p = dictionary_result (dict, md, i, 2);
if (p)
- info.email = xstrdup (p);
+ info.email = triplet_strdup (trp, p);
p = dictionary_result (dict, md, i, 3);
if (p)
- info.gpg_key = xstrdup (p);
+ info.gpg_key = triplet_strdup (trp, p);
if (debug_level > 3)
{
logmsg (LOG_DEBUG, _("name: %s"), SP (info.name));
logmsg (LOG_DEBUG, _("realname: %s"), SP (info.realname));
logmsg (LOG_DEBUG, _("gpg-key: %s"), SP (info.gpg_key));
@@ -275,16 +284,13 @@ verify_directive_file (struct file_triplet *trp)
if (!info.name || !info.realname || !info.gpg_key || !info.email)
{
logmsg (LOG_ERR,
_("project-uploader dictionary error: malformed row %lu"),
(unsigned long) i);
- free (info.name);
- free (info.realname);
- free (info.gpg_key);
- free (info.email);
+ /* FIXME: Memory not reclaimed */
continue;
}
ptr = new_uploader_info (&info);
if (tail)
tail->next = ptr;
diff --git a/src/vtab.c b/src/vtab.c
index 9854660..918bab3 100644
--- a/src/vtab.c
+++ b/src/vtab.c
@@ -51,47 +51,42 @@ url_to_vtab (mu_url_t url, struct virt_tab *vtab)
}
return 1;
}
int
-move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir)
+move_file (struct file_triplet *trp, enum file_type file_id)
{
- int rc = spool->vtab.move_file (trp, spool, file_id, reldir);
- report_add ("Move %s to %s: %s", trp->file[file_id].name, reldir,
+ int rc = trp->spool->vtab.move_file (trp, file_id);
+ report_add ("Move %s to %s: %s", trp->file[file_id].name, trp->relative_dir,
rc == 0 ? "OK" : "FAILED");
return rc;
}
int
-archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name)
+archive_file (struct file_triplet *trp, const char *file_name)
{
- int rc = spool->vtab.archive_file (trp, spool, reldir, file_name);
- report_add ("Archive and remove %s/%s: %s", reldir, file_name,
+ int rc = trp->spool->vtab.archive_file (trp, file_name);
+ report_add ("Archive and remove %s/%s: %s", trp->relative_dir, file_name,
rc == 0 ? "OK" : "FAILED");
return rc;
}
int
-symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst)
{
- int rc = spool->vtab.symlink_file (trp, spool, reldir,
- wanted_src, wanted_dst);
+ int rc = trp->spool->vtab.symlink_file (trp, wanted_src, wanted_dst);
report_add ("Symlink %s to %s in %s/: %s", wanted_src, wanted_dst,
- reldir,
+ trp->relative_dir,
rc == 0 ? "OK" : "FAILED");
return rc;
}
int
-rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name)
+rmsymlink_file (struct file_triplet *trp, const char *file_name)
{
- int rc = spool->vtab.rmsymlink_file (trp, spool, reldir, file_name);
- report_add ("Remove symlink %s/%s: %s", reldir, file_name,
+ int rc = trp->spool->vtab.rmsymlink_file (trp, file_name);
+ report_add ("Remove symlink %s/%s: %s", trp->relative_dir, file_name,
rc == 0 ? "OK" : "FAILED");
return rc;
}
diff --git a/src/wydawca.h b/src/wydawca.h
index b44b5d7..da093c3 100644
--- a/src/wydawca.h
+++ b/src/wydawca.h
@@ -171,16 +171,18 @@ struct uploader_info
/* File triplet */
struct file_triplet
{
char *name; /* Triplet base name */
struct file_info file[FILE_TYPE_COUNT]; /* Components */
const struct spool *spool; /* Owning spool */
+ char *relative_dir; /* Directory relative to spool->dest_dir */
char **directive; /* Decoded directive pairs (key: value\0) */
char *blurb; /* Block of directives: directive[i] points here */
char *tmp; /* Temporary storage */
size_t tmpsize; /* Size of memory allocated in tmp */
+ struct obstack obstk; /* Obstack for string allocation */
/* User data */
size_t uploader_count;
struct uploader_info *uploader_list;
struct uploader_info *uploader;
/* Special data for template formatting */
char *project; /* Triplet project name (if known) */
@@ -196,29 +198,18 @@ struct file_triplet
struct virt_tab
{
int (*test_url) (mu_url_t url, grecs_locus_t *loc);
- int (*move_file) (struct file_triplet *trp,
- const struct spool *spool,
- enum file_type file_id,
- const char *reldir);
- int (*archive_file) (struct file_triplet *trp,
- const struct spool *spool,
- const char *reldir,
- const char *file_name);
+ int (*move_file) (struct file_triplet *trp, enum file_type file_id);
+ int (*archive_file) (struct file_triplet *trp, const char *file_name);
int (*symlink_file) (struct file_triplet *trp,
- const struct spool *spool,
- const char *reldir,
const char *wanted_src,
const char *wanted_dst);
- int (*rmsymlink_file)(struct file_triplet *trp,
- const struct spool *spool,
- const char *reldir,
- const char *file_name);
+ int (*rmsymlink_file)(struct file_triplet *trp, const char *file_name);
};
/* An upload spool. This structure contains all data necessary for releasing
files from source to destination */
struct spool
{
@@ -463,12 +454,13 @@ int directive_next (struct file_triplet *trp, int n,
const char **pkey, const char **pval);
int process_directives (struct file_triplet *trp);
int enabled_spool_p (const struct spool *spool);
int selected_spools (void);
+char *triplet_strdup (struct file_triplet *tp, const char *str);
int parse_time_interval (const char *str, time_t *pint, const char **endp);
/* config.c */
@@ -479,51 +471,39 @@ int assert_string_arg (grecs_locus_t *, enum grecs_callback_command,
/* vtab.c */
int url_to_vtab (mu_url_t url, struct virt_tab *vtab);
int
-move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir);
+move_file (struct file_triplet *trp, enum file_type file_id);
int
-archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name);
+archive_file (struct file_triplet *trp, const char *file_name);
int
-symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst);
int
-rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name);
+rmsymlink_file (struct file_triplet *trp, const char *file_name);
/* diskio.c */
char *concat_dir (const char *base, const char *name, size_t *pbaselen);
int copy_file (const char *file, const char *dst_file);
int dir_test_url (mu_url_t url, grecs_locus_t *locus);
-int dir_move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir);
-int dir_archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *file_name, const char *reldir);
-int dir_symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+int dir_move_file (struct file_triplet *trp, enum file_type file_id);
+int dir_archive_file (struct file_triplet *trp, const char *reldir);
+int dir_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst);
-int dir_rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name);
+int dir_rmsymlink_file (struct file_triplet *trp, const char *file_name);
/* null.c */
-int null_move_file (struct file_triplet *trp, const struct spool *spool,
- enum file_type file_id, const char *reldir);
-int null_archive_file (struct file_triplet *trp, const struct spool *spool,
- const char *file_name, const char *reldir);
-int null_symlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir,
+int null_move_file (struct file_triplet *trp, enum file_type file_id);
+int null_archive_file (struct file_triplet *trp, const char *file_name);
+int null_symlink_file (struct file_triplet *trp,
const char *wanted_src, const char *wanted_dst);
-int null_rmsymlink_file (struct file_triplet *trp, const struct spool *spool,
- const char *reldir, const char *file_name);
+int null_rmsymlink_file (struct file_triplet *trp, const char *file_name);
/* timer.c */
typedef struct timer_slot *wydawca_timer_t;
wydawca_timer_t timer_get (const char *name);

Return to:

Send suggestions and report system problems to the System administrator.