Exchange of fprintf(stderr, ...) with avrdude_message(...).

This change was made for the shared library, since library functions
should not write to std-streams directly. Instead avrdude_message()
has to be implemented by the library user. For the avrdude application
this function is implemented in main.c.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1305 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Axel Wachtler
2014-05-18 08:41:46 +00:00
parent 52dd5cc7ac
commit eb5fcb581f
45 changed files with 2380 additions and 2896 deletions

View File

@@ -63,7 +63,7 @@ static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int
for(i = 0; i < PIN_MAX; i++) {
if(pindef->mask[i / PIN_FIELD_ELEMENT_SIZE] & (1 << (i % PIN_FIELD_ELEMENT_SIZE))) {
if(found) {
fprintf(stderr, "Multiple pins found\n"); //TODO
avrdude_message("Multiple pins found\n"); //TODO
return -1;
}
found = true;
@@ -88,7 +88,7 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
for(i = 0; i < PIN_FIELD_SIZE; i++) {
if(i == 0) {
if((pindef->mask[i] & ~PIN_MASK) != 0) {
fprintf(stderr, "Pins of higher index than max field size for old pinno found\n");
avrdude_message("Pins of higher index than max field size for old pinno found\n");
return -1;
}
if (pindef->mask[i] == 0) {
@@ -100,11 +100,11 @@ static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned i
} else if(pindef->mask[i] == ((~pindef->inverse[i]) & pindef->mask[i])) { /* all set bits in mask are cleared in inverse */
*pinno = pindef->mask[i];
} else {
fprintf(stderr, "pins have different polarity set\n");
avrdude_message("pins have different polarity set\n");
return -1;
}
} else if(pindef->mask[i] != 0) {
fprintf(stderr, "Pins have higher number than fit in old format\n");
avrdude_message("Pins have higher number than fit in old format\n");
return -1;
}
}
@@ -270,12 +270,10 @@ int pins_check(const struct programmer_t * const pgm, const struct pin_checklist
}
if(invalid) {
if(output) {
fprintf(stderr,
"%s: %s: Following pins are not valid pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(invalid_used));
avrdude_message("%s: %s: Following pins are not valid pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(invalid_used));
if(verbose >= 2) {
fprintf(stderr,
"%s: %s: Valid pins for this function are: %s\n",
avrdude_message("%s: %s: Valid pins for this function are: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->mask));
}
}
@@ -283,39 +281,34 @@ int pins_check(const struct programmer_t * const pgm, const struct pin_checklist
}
if(inverse) {
if(output) {
fprintf(stderr,
"%s: %s: Following pins are not usable as inverse pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(inverse_used));
avrdude_message("%s: %s: Following pins are not usable as inverse pins for this function: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(inverse_used));
if(verbose >= 2) {
fprintf(stderr,
"%s: %s: Valid inverse pins for this function are: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
avrdude_message("%s: %s: Valid inverse pins for this function are: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(valid_pins->inverse));
}
}
is_ok = false;
}
if(used) {
if(output) {
fprintf(stderr,
"%s: %s: Following pins are set for other functions too: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(already_used));
avrdude_message("%s: %s: Following pins are set for other functions too: %s\n",
progname, avr_pin_name(pinname), pinmask_to_str(already_used));
is_ok = false;
}
}
if(!mandatory_used && is_mandatory && !invalid) {
if(output) {
fprintf(stderr,
"%s: %s: Mandatory pin is not defined.\n",
progname, avr_pin_name(pinname));
avrdude_message("%s: %s: Mandatory pin is not defined.\n",
progname, avr_pin_name(pinname));
}
is_ok = false;
}
if(!is_ok) {
rv = -1;
} else if(output && verbose >= 3) {
fprintf(stderr,
"%s: %s: Pin is ok.\n",
progname, avr_pin_name(pinname));
avrdude_message("%s: %s: Pin is ok.\n",
progname, avr_pin_name(pinname));
}
}
return rv;
@@ -358,7 +351,7 @@ const char * pins_to_str(const struct pindef_t * const pindef) {
/**
* Returns the name of the pin as string.
*
*
* @param pinname the pinname which we want as string.
* @returns a string with the pinname, or <unknown> if pinname is invalid.
*/