summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/dpkg/trigdeferred.h27
-rw-r--r--lib/dpkg/trigdeferred.l29
-rw-r--r--lib/dpkg/triglib.c22
-rw-r--r--src/trigcmd.c18
4 files changed, 49 insertions, 47 deletions
diff --git a/lib/dpkg/trigdeferred.h b/lib/dpkg/trigdeferred.h
index 3837c025d..fbb086841 100644
--- a/lib/dpkg/trigdeferred.h
+++ b/lib/dpkg/trigdeferred.h
@@ -4,6 +4,7 @@
*
* Copyright © 2007 Canonical, Ltd.
* written by Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,21 +33,21 @@ DPKG_BEGIN_DECLS
* @{
*/
-enum trigdef_updateflags {
- tduf_nolockok = DPKG_BIT(0),
- tduf_write = DPKG_BIT(1),
- tduf_nolock = tduf_nolockok | tduf_write,
- /** Should not be set unless _write is. */
- tduf_writeifempty = DPKG_BIT(3),
- tduf_writeifenoent = DPKG_BIT(4),
+enum trigdef_update_flags {
+ TDUF_NO_LOCK_OK = DPKG_BIT(0),
+ TDUF_WRITE = DPKG_BIT(1),
+ TDUF_NO_LOCK = TDUF_NO_LOCK_OK | TDUF_WRITE,
+ /** Should not be set unless TDUF_WRITE is. */
+ TDUF_WRITE_IF_EMPTY = DPKG_BIT(3),
+ TDUF_WRITE_IF_ENOENT = DPKG_BIT(4),
};
enum trigdef_update_status {
- tdus_error_no_dir = -1,
- tdus_error_empty_deferred = -2,
- tdus_error_no_deferred = -3,
- tdus_no_deferred = 1,
- tdus_ok = 2,
+ TDUS_ERROR_NO_DIR = -1,
+ TDUS_ERROR_EMPTY_DEFERRED = -2,
+ TDUS_ERROR_NO_DEFERRED = -3,
+ TDUS_NO_DEFERRED = 1,
+ TDUS_OK = 2,
};
struct trigdefmeths {
@@ -57,7 +58,7 @@ struct trigdefmeths {
void trigdef_set_methods(const struct trigdefmeths *methods);
-enum trigdef_update_status trigdef_update_start(enum trigdef_updateflags uf);
+enum trigdef_update_status trigdef_update_start(enum trigdef_update_flags uf);
void trigdef_update_printf(const char *format, ...) DPKG_ATTR_PRINTF(1);
int trigdef_parse(void);
void trigdef_process_done(void);
diff --git a/lib/dpkg/trigdeferred.l b/lib/dpkg/trigdeferred.l
index 081961a31..af4f9a952 100644
--- a/lib/dpkg/trigdeferred.l
+++ b/lib/dpkg/trigdeferred.l
@@ -4,6 +4,7 @@
*
* Copyright © 2007 Canonical Ltd
* written by Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -111,28 +112,28 @@ constructfn(struct varbuf *vb, const char *dir, const char *tail)
* Start processing of the triggers deferred file.
*
* @retval -1 Lock ENOENT with O_CREAT (directory does not exist).
- * @retval -2 Unincorp empty, tduf_writeifempty unset.
- * @retval -3 Unincorp ENOENT, tduf_writeifenoent unset.
- * @retval 1 Unincorp ENOENT, tduf_writeifenoent set.
+ * @retval -2 Unincorp empty, TDUF_WRITE_IF_EMPTY unset.
+ * @retval -3 Unincorp ENOENT, TDUF_WRITE_IF_ENOENT unset.
+ * @retval 1 Unincorp ENOENT, TDUF_WRITE_IF_ENOENT set.
* @retval 2 Ok.
*
* For positive return values the caller must call trigdef_update_done!
*/
enum trigdef_update_status
-trigdef_update_start(enum trigdef_updateflags uf)
+trigdef_update_start(enum trigdef_update_flags uf)
{
triggersdir = dpkg_db_get_path(TRIGGERSDIR);
- if (uf & tduf_write) {
+ if (uf & TDUF_WRITE) {
constructfn(&fn, triggersdir, TRIGGERSLOCKFILE);
if (lock_fd == -1) {
lock_fd = open(fn.buf, O_RDWR | O_CREAT | O_TRUNC, 0600);
if (lock_fd == -1) {
- if (!(errno == ENOENT && (uf & tduf_nolockok)))
+ if (!(errno == ENOENT && (uf & TDUF_NO_LOCK_OK)))
ohshite(_("unable to open/create "
"triggers lockfile `%.250s'"),
fn.buf);
- return tdus_error_no_dir;
+ return TDUS_ERROR_NO_DIR;
}
}
@@ -151,9 +152,9 @@ trigdef_update_start(enum trigdef_updateflags uf)
if (errno != ENOENT)
ohshite(_("unable to open triggers deferred file `%.250s'"),
fn.buf);
- if (!(uf & tduf_writeifenoent)) {
+ if (!(uf & TDUF_WRITE_IF_ENOENT)) {
pop_cleanup(ehflag_normaltidy);
- return tdus_error_no_deferred;
+ return TDUS_ERROR_NO_DEFERRED;
}
} else {
struct stat stab;
@@ -164,13 +165,13 @@ trigdef_update_start(enum trigdef_updateflags uf)
ohshite(_("unable to stat triggers deferred file `%.250s'"),
fn.buf);
- if (stab.st_size == 0 && !(uf & tduf_writeifempty)) {
+ if (stab.st_size == 0 && !(uf & TDUF_WRITE_IF_EMPTY)) {
pop_cleanup(ehflag_normaltidy);
- return tdus_error_empty_deferred;
+ return TDUS_ERROR_EMPTY_DEFERRED;
}
}
- if (uf & tduf_write) {
+ if (uf & TDUF_WRITE) {
constructfn(&newfn, triggersdir, TRIGGERSDEFERREDFILE ".new");
if (trig_new_deferred)
fclose(trig_new_deferred);
@@ -181,12 +182,12 @@ trigdef_update_start(enum trigdef_updateflags uf)
}
if (!old_deferred)
- return tdus_no_deferred;
+ return TDUS_NO_DEFERRED;
trigdef_yyrestart(old_deferred);
BEGIN(0);
- return tdus_ok;
+ return TDUS_OK;
}
void
diff --git a/lib/dpkg/triglib.c b/lib/dpkg/triglib.c
index 043a11885..b04a7b8d2 100644
--- a/lib/dpkg/triglib.c
+++ b/lib/dpkg/triglib.c
@@ -4,7 +4,7 @@
*
* Copyright © 2007 Canonical Ltd
* Written by Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -752,7 +752,7 @@ void
trig_incorporate(enum modstatdb_rw cstatus)
{
enum trigdef_update_status ur;
- enum trigdef_updateflags tduf;
+ enum trigdef_update_flags tduf;
free(triggersdir);
triggersdir = dpkg_db_get_path(TRIGGERSDIR);
@@ -763,15 +763,15 @@ trig_incorporate(enum modstatdb_rw cstatus)
trigdef_set_methods(&tdm_incorp);
trig_file_interests_ensure();
- tduf = tduf_nolockok;
+ tduf = TDUF_NO_LOCK_OK;
if (cstatus >= msdbrw_write) {
- tduf |= tduf_write;
+ tduf |= TDUF_WRITE;
if (trigh.transitional_activate)
- tduf |= tduf_writeifenoent;
+ tduf |= TDUF_WRITE_IF_ENOENT;
}
ur = trigdef_update_start(tduf);
- if (ur == tdus_error_no_dir && cstatus >= msdbrw_write) {
+ if (ur == TDUS_ERROR_NO_DIR && cstatus >= msdbrw_write) {
if (mkdir(triggersdir, 0755)) {
if (errno != EEXIST)
ohshite(_("unable to create triggers state"
@@ -783,17 +783,17 @@ trig_incorporate(enum modstatdb_rw cstatus)
ur = trigdef_update_start(tduf);
}
switch (ur) {
- case tdus_error_empty_deferred:
+ case TDUS_ERROR_EMPTY_DEFERRED:
return;
- case tdus_error_no_dir:
- case tdus_error_no_deferred:
+ case TDUS_ERROR_NO_DIR:
+ case TDUS_ERROR_NO_DEFERRED:
if (!trigh.transitional_activate)
return;
/* Fall through. */
- case tdus_no_deferred:
+ case TDUS_NO_DEFERRED:
trigh.transitional_activate(cstatus);
break;
- case tdus_ok:
+ case TDUS_OK:
/* Read and incorporate triggers. */
trigdef_parse();
break;
diff --git a/src/trigcmd.c b/src/trigcmd.c
index c3ec7e728..2df7a3537 100644
--- a/src/trigcmd.c
+++ b/src/trigcmd.c
@@ -3,7 +3,7 @@
*
* Copyright © 2007 Canonical Ltd.
* Written by Ian Jackson <ian@davenant.greenend.org.uk>
- * Copyright © 2008-2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -174,16 +174,16 @@ do_check(void)
{
enum trigdef_update_status uf;
- uf = trigdef_update_start(tduf_nolockok);
+ uf = trigdef_update_start(TDUF_NO_LOCK_OK);
switch (uf) {
- case tdus_error_no_dir:
+ case TDUS_ERROR_NO_DIR:
notice(_("triggers data directory not yet created"));
exit(1);
- case tdus_error_no_deferred:
+ case TDUS_ERROR_NO_DEFERRED:
notice(_("trigger records not yet in existence"));
exit(1);
- case tdus_ok:
- case tdus_error_empty_deferred:
+ case TDUS_OK:
+ case TDUS_ERROR_EMPTY_DEFERRED:
exit(0);
default:
internerr("unknown trigdef_update_start return value '%d'", uf);
@@ -205,7 +205,7 @@ int
main(int argc, const char *const *argv)
{
const char *badname;
- enum trigdef_updateflags tduf;
+ enum trigdef_update_flags tduf;
enum trigdef_update_status tdus;
dpkg_locales_init(PACKAGE);
@@ -237,9 +237,9 @@ main(int argc, const char *const *argv)
trigdef_set_methods(&tdm_add);
- tduf = tduf_nolockok;
+ tduf = TDUF_NO_LOCK_OK;
if (!f_noact)
- tduf |= tduf_write | tduf_writeifempty;
+ tduf |= TDUF_WRITE | TDUF_WRITE_IF_EMPTY;
tdus = trigdef_update_start(tduf);
if (tdus >= 0) {
trigdef_parse();