diff options
author | Guillem Jover <guillem@debian.org> | 2014-05-28 00:57:51 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-05-28 00:57:51 +0200 |
commit | b22d8a95e38e187cf0e4e870cb892b42cca57ebd (patch) | |
tree | 349d69aec6668c8074be7927ab552aa9d551e709 /lib | |
parent | 8d49206ec2887e0c726efea4dafe874211fbc045 (diff) | |
download | dpkg-b22d8a95e38e187cf0e4e870cb892b42cca57ebd.tar.gz |
libdpkg: Uppercase trigdef enum values and separate words with underscores
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dpkg/trigdeferred.h | 27 | ||||
-rw-r--r-- | lib/dpkg/trigdeferred.l | 29 | ||||
-rw-r--r-- | lib/dpkg/triglib.c | 22 |
3 files changed, 40 insertions, 38 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; |