From: Michael Tremer Date: Wed, 30 Jun 2021 17:08:52 +0000 (+0000) Subject: transactions: Move PAKFIRE_ACTION_* and PAKFIRE_STEP_* X-Git-Tag: 0.9.28~1144 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d2d7113e109aecfcac9d672f499b211e5240e2b;p=pakfire.git transactions: Move PAKFIRE_ACTION_* and PAKFIRE_STEP_* Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/types.h b/src/libpakfire/include/pakfire/types.h index 24d50c687..a9a906a1f 100644 --- a/src/libpakfire/include/pakfire/types.h +++ b/src/libpakfire/include/pakfire/types.h @@ -35,22 +35,4 @@ typedef struct _PakfireSolution* PakfireSolution; typedef void (*pakfire_log_function_t)(void* data, int priority, const char* file, int line, const char* fn, const char* format, va_list args); -typedef enum _pakfire_action_types { - PAKFIRE_ACTION_NOOP = 0, - PAKFIRE_ACTION_VERIFY = 1 << 0, - PAKFIRE_ACTION_EXECUTE = 1 << 1, - PAKFIRE_ACTION_PRETRANS = 1 << 2, - PAKFIRE_ACTION_POSTTRANS = 1 << 3, -} pakfire_action_type_t; - -typedef enum _pakfire_step_types { - PAKFIRE_STEP_IGNORE = 0, - PAKFIRE_STEP_INSTALL, - PAKFIRE_STEP_REINSTALL, - PAKFIRE_STEP_ERASE, - PAKFIRE_STEP_UPGRADE, - PAKFIRE_STEP_DOWNGRADE, - PAKFIRE_STEP_OBSOLETE, -} pakfire_step_type_t; - #endif /* PAKFIRE_TYPES_H */ diff --git a/src/libpakfire/transaction.c b/src/libpakfire/transaction.c index a2cf3b72b..097800ca8 100644 --- a/src/libpakfire/transaction.c +++ b/src/libpakfire/transaction.c @@ -52,7 +52,25 @@ struct pakfire_transaction { size_t num; }; -static pakfire_step_type_t pakfire_transaction_get_step_type( +enum pakfire_actions { + PAKFIRE_ACTION_NOOP = 0, + PAKFIRE_ACTION_VERIFY, + PAKFIRE_ACTION_EXECUTE, + PAKFIRE_ACTION_PRETRANS, + PAKFIRE_ACTION_POSTTRANS, +}; + +enum pakfire_steps { + PAKFIRE_STEP_IGNORE = 0, + PAKFIRE_STEP_INSTALL, + PAKFIRE_STEP_REINSTALL, + PAKFIRE_STEP_ERASE, + PAKFIRE_STEP_UPGRADE, + PAKFIRE_STEP_DOWNGRADE, + PAKFIRE_STEP_OBSOLETE, +}; + +static enum pakfire_steps pakfire_transaction_get_step_type( struct pakfire_transaction* transaction, struct pakfire_package* pkg) { int type = transaction_type(transaction->transaction, pakfire_package_id(pkg), SOLVER_TRANSACTION_SHOW_ACTIVE|SOLVER_TRANSACTION_CHANGE_IS_REINSTALL); @@ -655,7 +673,7 @@ ERROR: return r; } -static const char* pakfire_action_type_string(pakfire_action_type_t type) { +static const char* pakfire_action_type_string(enum pakfire_actions type) { switch (type) { case PAKFIRE_ACTION_NOOP: return "NOOP"; @@ -695,7 +713,7 @@ static int pakfire_transaction_package_is_userinstalled( } static int pakfire_transaction_run_step(struct pakfire_transaction* transaction, - struct pakfire_db* db, const pakfire_action_type_t action, struct pakfire_package* pkg, PakfireArchive archive) { + struct pakfire_db* db, const enum pakfire_actions action, struct pakfire_package* pkg, PakfireArchive archive) { if (!pkg) { errno = EINVAL; return 1; @@ -704,7 +722,7 @@ static int pakfire_transaction_run_step(struct pakfire_transaction* transaction, DEBUG(transaction->pakfire, "Running %s for %s\n", pakfire_action_type_string(action), pakfire_package_get_nevra(pkg)); - pakfire_step_type_t type = pakfire_transaction_get_step_type(transaction, pkg); + enum pakfire_steps type = pakfire_transaction_get_step_type(transaction, pkg); int r = 0; switch (action) { @@ -851,7 +869,7 @@ static int pakfire_transaction_run_step(struct pakfire_transaction* transaction, } static int pakfire_transaction_run_steps(struct pakfire_transaction* transaction, - struct pakfire_db* db, const pakfire_action_type_t action) { + struct pakfire_db* db, enum pakfire_actions action) { int r = 0; // Walk through all steps @@ -874,7 +892,7 @@ static int pakfire_transaction_open_archives(struct pakfire_transaction* transac struct pakfire_package* pkg = transaction->packages[i]; // Fetch the type - pakfire_step_type_t type = pakfire_transaction_get_step_type(transaction, pkg); + enum pakfire_steps type = pakfire_transaction_get_step_type(transaction, pkg); // Do we need the archive? switch (type) { @@ -1004,7 +1022,7 @@ ERROR: static int pakfire_transaction_package_needs_download( struct pakfire_transaction* transaction, struct pakfire_package* pkg) { - pakfire_step_type_t type = pakfire_transaction_get_step_type(transaction, pkg); + enum pakfire_steps type = pakfire_transaction_get_step_type(transaction, pkg); switch (type) { case PAKFIRE_STEP_INSTALL: case PAKFIRE_STEP_REINSTALL: