Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-01-24 03:02:53 +0000
committerAaron Griffin <aaron@archlinux.org>2007-01-24 03:02:53 +0000
commit1b61cc8c69025ddd394401a506b21f16df5d4e6d (patch)
treec99b4717e8eeb23295603d60eb97e27cc821a730 /src
parent838767205319e5d436194cc4a5aaa08ccf4f6077 (diff)
This mainly deals with code clarity- removing currently unneeded
optimizations in order to make the code much more readable and type-checkable. Every enum in the library now has it's own type that should be used instead of the generic 'unsigned char'. In addition, several #define statements dealing with constants were converted to enums. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/add.c14
-rw-r--r--src/pacman/deptest.c14
-rw-r--r--src/pacman/sync.c19
-rw-r--r--src/pacman/trans.c78
-rw-r--r--src/pacman/trans.h8
5 files changed, 83 insertions, 50 deletions
diff --git a/src/pacman/add.c b/src/pacman/add.c
index 6a23531d..1dedbafb 100644
--- a/src/pacman/add.c
+++ b/src/pacman/add.c
@@ -96,9 +96,17 @@ int pacman_add(alpm_list_t *targets)
MSG(NL, _(":: %s: requires %s"), alpm_dep_get_target(miss),
alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index e5306579..a46141db 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -114,9 +114,17 @@ int pacman_deptest(alpm_list_t *targets)
if(!config->op_d_resolve) {
MSG(NL, _("requires: %s"), alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 36fe612f..6288ac50 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -579,12 +579,21 @@ int pacman_sync(alpm_list_t *targets)
for(i = data; i; i = alpm_list_next(i)) {
pmdepmissing_t *miss = alpm_list_getdata(i);
MSG(NL, ":: %s %s %s", alpm_dep_get_target(miss),
- alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ? _("requires") : _("is required by"),
- alpm_dep_get_name(miss));
+ alpm_dep_get_type(miss) == PM_DEP_TYPE_DEPEND ?
+ _("requires") : _("is required by"),
+ alpm_dep_get_name(miss));
switch(alpm_dep_get_mod(miss)) {
- case PM_DEP_MOD_EQ: MSG(CL, "=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_GE: MSG(CL, ">=%s", alpm_dep_get_version(miss)); break;
- case PM_DEP_MOD_LE: MSG(CL, "<=%s", alpm_dep_get_version(miss)); break;
+ case PM_DEP_MOD_ANY:
+ break;
+ case PM_DEP_MOD_EQ:
+ MSG(CL, "=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_GE:
+ MSG(CL, ">=%s", alpm_dep_get_version(miss));
+ break;
+ case PM_DEP_MOD_LE:
+ MSG(CL, "<=%s", alpm_dep_get_version(miss));
+ break;
}
MSG(CL, "\n");
}
diff --git a/src/pacman/trans.c b/src/pacman/trans.c
index d217ed24..156094e6 100644
--- a/src/pacman/trans.c
+++ b/src/pacman/trans.c
@@ -44,7 +44,7 @@ static int prevpercent=0; /* for less progressbar output */
/* Callback to handle transaction events
*/
-void cb_trans_evt(unsigned char event, void *data1, void *data2)
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
{
char str[LOG_STR_LEN] = "";
char out[PATH_MAX];
@@ -53,38 +53,42 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
switch(event) {
case PM_TRANS_EVT_CHECKDEPS_START:
pm_fprintf(stderr, NL, _("checking dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) {
MSG(NL, _("checking for file conflicts... "));
}
- break;
+ break;
+ case PM_TRANS_EVT_CLEANUP_START:
+ pm_fprintf(stderr, NL, _("resolving dependencies... "));
+ break;
case PM_TRANS_EVT_RESOLVEDEPS_START:
pm_fprintf(stderr, NL, _("resolving dependencies... "));
- break;
+ break;
case PM_TRANS_EVT_INTERCONFLICTS_START:
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
- break;
+ break;
case PM_TRANS_EVT_FILECONFLICTS_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_CHECKDEPS_DONE:
+ case PM_TRANS_EVT_CLEANUP_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
pm_fprintf(stderr, CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_EXTRACT_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_START:
if(config->noprogressbar) {
MSG(NL, _("installing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_ADD_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -93,12 +97,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_REMOVE_START:
if(config->noprogressbar) {
MSG(NL, _("removing %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_REMOVE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -107,12 +111,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
alpm_pkg_get_name(data1),
alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_START:
if(config->noprogressbar) {
MSG(NL, _("upgrading %s... "), alpm_pkg_get_name(data1));
}
- break;
+ break;
case PM_TRANS_EVT_UPGRADE_DONE:
if(config->noprogressbar) {
MSG(CL, _("done.\n"));
@@ -122,34 +126,34 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
(char *)alpm_pkg_get_version(data2),
(char *)alpm_pkg_get_version(data1));
alpm_logaction(str);
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_START:
MSG(NL, _("checking package integrity... "));
- break;
+ break;
case PM_TRANS_EVT_INTEGRITY_DONE:
MSG(CL, _("done.\n"));
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_INFO:
MSG(NL, "%s\n", (char*)data1);
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_START:
MSG(NL, (char*)data1);
MSG(CL, "...");
- break;
+ break;
case PM_TRANS_EVT_SCRIPTLET_DONE:
if(!(long)data1) {
MSG(CL, _(" done.\n"));
} else {
MSG(CL, _(" failed.\n"));
}
- break;
+ break;
case PM_TRANS_EVT_PRINTURI:
MSG(NL, "%s/%s\n", (char*)data1, (char*)data2);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_START:
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
fflush(stdout);
- break;
+ break;
case PM_TRANS_EVT_RETRIEVE_LOCAL:
MSG(NL, " %s [", (char*)data1);
unsigned int maxcols = getcols();
@@ -159,11 +163,12 @@ void cb_trans_evt(unsigned char event, void *data1, void *data2)
MSG(CL, " ");
}
fputs(_("] 100% LOCAL "), stdout);
- break;
+ break;
}
}
-void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response)
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response)
{
char str[LOG_STR_LEN] = "";
@@ -181,7 +186,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REMOVE_HOLDPKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REMOVE_HOLDPKG) {
@@ -190,11 +195,11 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
*response = 0;
}
} else {
- snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
+ snprintf(str, LOG_STR_LEN, _(":: %s is designated as a HoldPkg. Remove anyway? [Y/n] "),
alpm_pkg_get_name(data1));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_REPLACE_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_REPLACE_PKG) {
@@ -209,7 +214,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
alpm_pkg_get_name(data2));
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_CONFLICT_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CONFLICT_PKG) {
@@ -224,7 +229,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
(char *)data2);
*response = yesno(str);
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_NEWER:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_NEWER) {
@@ -242,7 +247,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_LOCAL_UPTODATE:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_LOCAL_UPTODATE) {
@@ -260,7 +265,7 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
*response = 1;
}
}
- break;
+ break;
case PM_TRANS_CONV_CORRUPTED_PKG:
if(config->noask) {
if(config->ask & PM_TRANS_CONV_CORRUPTED_PKG) {
@@ -277,11 +282,12 @@ void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, i
*response = 1;
}
}
- break;
+ break;
}
}
-void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain)
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain)
{
static int lasthash = 0, mouth = 0;
int i, hash;
@@ -311,19 +317,19 @@ void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howm
switch (event) {
case PM_TRANS_PROGRESS_ADD_START:
ptr = _("installing");
- break;
+ break;
case PM_TRANS_PROGRESS_UPGRADE_START:
ptr = _("upgrading");
- break;
+ break;
case PM_TRANS_PROGRESS_REMOVE_START:
ptr = _("removing");
- break;
+ break;
case PM_TRANS_PROGRESS_CONFLICTS_START:
ptr = _("checking for file conflicts");
- break;
+ break;
}
hash=percent*progresslen/100;
diff --git a/src/pacman/trans.h b/src/pacman/trans.h
index baed0d1e..1e08dff6 100644
--- a/src/pacman/trans.h
+++ b/src/pacman/trans.h
@@ -22,12 +22,14 @@
#define _PM_TRANS_H
/* callback to handle messages/notifications from pacman transactions */
-void cb_trans_evt(unsigned char event, void *data1, void *data2);
+void cb_trans_evt(pmtransevt_t event, void *data1, void *data2);
/* callback to handle questions from pacman transactions (yes/no) */
-void cb_trans_conv(unsigned char event, void *data1, void *data2, void *data3, int *response);
+void cb_trans_conv(pmtransconv_t event, void *data1, void *data2,
+ void *data3, int *response);
-void cb_trans_progress(unsigned char event, char *pkgname, int percent, int howmany, int remain);
+void cb_trans_progress(pmtransprog_t event, char *pkgname, int percent,
+ int howmany, int remain);
#endif /* _PM_TRANS_H */