* Cleaned up direct pm_fprintf usage (move to MSG/ERR macros for now)

* Moved some stderr output to stdout
* Remove "RETRIEVE_LOCAL" trans event as libdownload handles local files
This commit is contained in:
Aaron Griffin 2007-02-09 16:02:01 +00:00
parent 4e0b649c3a
commit d8fd645c4c
3 changed files with 12 additions and 28 deletions

View File

@ -173,7 +173,9 @@ int yesno(char *fmt, ...)
va_start(args, fmt);
vsnprintf(str, LOG_STR_LEN, fmt, args);
va_end(args);
pm_fprintf(stderr, NL, str);
/* Use stderr so questions are always displayed when redirecting output */
ERR(NL, str);
if(fgets(response, 32, stdin)) {
/* trim whitespace and newlines */

View File

@ -184,6 +184,7 @@ static void cleanup(int signum)
return;
}
if(signum != 0 && config->op_d_vertest == 0) {
/* TODO why is this here? */
fprintf(stderr, "\n");
}
@ -295,7 +296,7 @@ static int parseargs(int argc, char *argv[])
case 2: logmask |= PM_LOG_DOWNLOAD; /*fall through */
case 1: logmask |= PM_LOG_DEBUG; break;
default:
pm_fprintf(stderr, NL, _("error: '%s' is not a valid debug level"), optarg);
ERR(NL, _("error: '%s' is not a valid debug level"), optarg);
return(1);
}
printf("logmask = %d\n", logmask);
@ -331,7 +332,7 @@ static int parseargs(int argc, char *argv[])
break;
case 'b':
if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) {
pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg);
ERR(NL, _("error: '%s' is not a valid db path\n"), optarg);
return(1);
}
alpm_option_set_dbpath(optarg);
@ -361,7 +362,7 @@ static int parseargs(int argc, char *argv[])
break;
case 'r':
if(realpath(optarg, root) == NULL) {
pm_fprintf(stderr, NL, _("error: '%s' is not a valid root path\n"), optarg);
ERR(NL, _("error: '%s' is not a valid root path\n"), optarg);
return(1);
}
alpm_option_set_root(strdup(root));

View File

@ -41,22 +41,6 @@ extern config_t *config;
static int prevpercent=0; /* for less progressbar output */
/* refactored function from cb_trans_evt */
static void retrieve_local(void *data1, void *data2)
{
const unsigned int maxcols = getcols();
char out[PATH_MAX];
unsigned int i;
MSG(NL, " %s [", (char*)data1);
STRNCPY(out, (char*)data2, maxcols-42);
MSG(CL, "%s", out);
for(i = strlen(out); i < maxcols-43; i++) {
MSG(CL, " ");
}
fputs(_("] 100% LOCAL "), stdout);
}
/* Callback to handle transaction events
*/
void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
@ -65,7 +49,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
switch(event) {
case PM_TRANS_EVT_CHECKDEPS_START:
pm_fprintf(stderr, NL, _("checking dependencies... "));
MSG(NL, _("checking dependencies... "));
break;
case PM_TRANS_EVT_FILECONFLICTS_START:
if(config->noprogressbar) {
@ -73,13 +57,13 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
}
break;
case PM_TRANS_EVT_CLEANUP_START:
pm_fprintf(stderr, NL, _("cleaning up... "));
MSG(NL, _("cleaning up... "));
break;
case PM_TRANS_EVT_RESOLVEDEPS_START:
pm_fprintf(stderr, NL, _("resolving dependencies... "));
MSG(NL, _("resolving dependencies... "));
break;
case PM_TRANS_EVT_INTERCONFLICTS_START:
pm_fprintf(stderr, NL, _("looking for inter-conflicts... "));
MSG(NL, _("looking for inter-conflicts... "));
break;
case PM_TRANS_EVT_FILECONFLICTS_DONE:
if(config->noprogressbar) {
@ -90,7 +74,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
case PM_TRANS_EVT_CLEANUP_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
pm_fprintf(stderr, CL, _("done.\n"));
MSG(CL, _("done.\n"));
break;
case PM_TRANS_EVT_EXTRACT_DONE:
if(config->noprogressbar) {
@ -167,9 +151,6 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
MSG(NL, _(":: Retrieving packages from %s...\n"), (char*)data1);
fflush(stdout);
break;
case PM_TRANS_EVT_RETRIEVE_LOCAL:
retrieve_local(data1, data2);
break;
}
}