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

@@ -276,20 +276,19 @@ prog_def :
PROGRAMMER * existing_prog;
char * id;
if (lsize(current_prog->id) == 0) {
fprintf(stderr,
"%s: error at %s:%d: required parameter id not specified\n",
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
progname, infile, lineno);
exit(1);
}
if (current_prog->initpgm == NULL) {
fprintf(stderr, "%s: error at %s:%d: programmer type not specified\n",
avrdude_message("%s: error at %s:%d: programmer type not specified\n",
progname, infile, lineno);
exit(1);
}
id = ldata(lfirst(current_prog->id));
existing_prog = locate_programmer(programmers, id);
if (existing_prog) {
fprintf(stderr, "%s: warning at %s:%d: programmer %s overwrites "
avrdude_message("%s: warning at %s:%d: programmer %s overwrites "
"previous definition %s:%d.\n",
progname, infile, current_prog->lineno,
id, existing_prog->config_file, existing_prog->lineno);
@@ -315,8 +314,7 @@ prog_decl :
{
struct programmer_t * pgm = locate_programmer(programmers, $3->value.string);
if (pgm == NULL) {
fprintf(stderr,
"%s: error at %s:%d: parent programmer %s not found\n",
avrdude_message("%s: error at %s:%d: parent programmer %s not found\n",
progname, infile, lineno, $3->value.string);
exit(1);
}
@@ -336,8 +334,7 @@ part_def :
AVRPART * existing_part;
if (current_part->id[0] == 0) {
fprintf(stderr,
"%s: error at %s:%d: required parameter id not specified\n",
avrdude_message("%s: error at %s:%d: required parameter id not specified\n",
progname, infile, lineno);
exit(1);
}
@@ -351,22 +348,19 @@ part_def :
m = ldata(ln);
if (m->paged) {
if (m->page_size == 0) {
fprintf(stderr,
"%s: error at %s:%d: must specify page_size for paged "
avrdude_message("%s: error at %s:%d: must specify page_size for paged "
"memory\n",
progname, infile, lineno);
exit(1);
}
if (m->num_pages == 0) {
fprintf(stderr,
"%s: error at %s:%d: must specify num_pages for paged "
avrdude_message("%s: error at %s:%d: must specify num_pages for paged "
"memory\n",
progname, infile, lineno);
exit(1);
}
if (m->size != m->page_size * m->num_pages) {
fprintf(stderr,
"%s: error at %s:%d: page size (%u) * num_pages (%u) = "
avrdude_message("%s: error at %s:%d: page size (%u) * num_pages (%u) = "
"%u does not match memory size (%u)\n",
progname, infile, lineno,
m->page_size,
@@ -381,7 +375,7 @@ part_def :
existing_part = locate_part(part_list, current_part->id);
if (existing_part) {
fprintf(stderr, "%s: warning at %s:%d: part %s overwrites "
avrdude_message("%s: warning at %s:%d: part %s overwrites "
"previous definition %s:%d.\n",
progname, infile, current_part->lineno, current_part->id,
existing_part->config_file, existing_part->lineno);
@@ -404,8 +398,7 @@ part_decl :
{
AVRPART * parent_part = locate_part(part_list, $3->value.string);
if (parent_part == NULL) {
fprintf(stderr,
"%s: error at %s:%d: can't find parent part",
avrdude_message("%s: error at %s:%d: can't find parent part",
progname, infile, lineno);
exit(1);
}
@@ -474,8 +467,7 @@ prog_parm_type_id:
TKN_STRING {
const struct programmer_type_t * pgm_type = locate_programmer_type($1->value.string);
if (pgm_type == NULL) {
fprintf(stderr,
"%s: error at %s:%d: programmer type %s not found\n",
avrdude_message("%s: error at %s:%d: programmer type %s not found\n",
progname, infile, lineno, $1->value.string);
exit(1);
}
@@ -484,8 +476,7 @@ prog_parm_type_id:
}
| error
{
fprintf(stderr,
"%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
avrdude_message("%s: error at %s:%d: programmer type must be written as \"id_type\"\n",
progname, infile, lineno);
exit(1);
}
@@ -657,8 +648,7 @@ part_parm :
K_DEVICECODE TKN_EQUAL TKN_NUMBER {
{
fprintf(stderr,
"%s: error at %s:%d: devicecode is deprecated, use "
avrdude_message("%s: error at %s:%d: devicecode is deprecated, use "
"stk500_devcode instead\n",
progname, infile, lineno);
exit(1);
@@ -723,8 +713,7 @@ part_parm :
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
avrdude_message("%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
@@ -757,8 +746,7 @@ part_parm :
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
avrdude_message("%s: Warning: line %d of %s: "
"too many bytes in control stack\n",
progname, lineno, infile);
}
@@ -790,8 +778,7 @@ part_parm :
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
avrdude_message("%s: Warning: line %d of %s: "
"too many bytes in flash instructions\n",
progname, lineno, infile);
}
@@ -823,8 +810,7 @@ part_parm :
}
if (!ok)
{
fprintf(stderr,
"%s: Warning: line %d of %s: "
avrdude_message("%s: Warning: line %d of %s: "
"too many bytes in EEPROM instructions\n",
progname, lineno, infile);
}
@@ -1230,8 +1216,7 @@ part_parm :
op = avr_new_opcode();
parse_cmdbits(op);
if (current_part->op[opnum] != NULL) {
/*fprintf(stderr,
"%s: warning at %s:%d: operation redefined\n",
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
progname, infile, lineno);*/
avr_free_opcode(current_part->op[opnum]);
}
@@ -1357,8 +1342,7 @@ mem_spec :
op = avr_new_opcode();
parse_cmdbits(op);
if (current_mem->op[opnum] != NULL) {
/*fprintf(stderr,
"%s: warning at %s:%d: operation redefined\n",
/*avrdude_message("%s: warning at %s:%d: operation redefined\n",
progname, infile, lineno);*/
avr_free_opcode(current_mem->op[opnum]);
}
@@ -1394,8 +1378,7 @@ static int assign_pin(int pinno, TOKEN * v, int invert)
free_token(v);
if ((value < PIN_MIN) || (value > PIN_MAX)) {
fprintf(stderr,
"%s: error at line %d of %s: pin must be in the "
avrdude_message("%s: error at line %d of %s: pin must be in the "
"range %d-%d\n",
progname, lineno, infile, PIN_MIN, PIN_MAX);
exit(1);
@@ -1416,8 +1399,7 @@ static int assign_pin_list(int invert)
t = lrmv_n(number_list, 1);
pin = t->value.number;
if ((pin < PIN_MIN) || (pin > PIN_MAX)) {
fprintf(stderr,
"%s: error at line %d of %s: pin must be in the "
avrdude_message("%s: error at line %d of %s: pin must be in the "
"range %d-%d\n",
progname, lineno, infile, PIN_MIN, PIN_MAX);
exit(1);
@@ -1446,8 +1428,7 @@ static int which_opcode(TOKEN * opcode)
case K_CHIP_ERASE : return AVR_OP_CHIP_ERASE; break;
case K_PGM_ENABLE : return AVR_OP_PGM_ENABLE; break;
default :
fprintf(stderr,
"%s: error at %s:%d: invalid opcode\n",
avrdude_message("%s: error at %s:%d: invalid opcode\n",
progname, infile, lineno);
exit(1);
break;
@@ -1475,8 +1456,7 @@ static int parse_cmdbits(OPCODE * op)
bitno--;
if (bitno < 0) {
fprintf(stderr,
"%s: error at %s:%d: too many opcode bits for instruction\n",
avrdude_message("%s: error at %s:%d: too many opcode bits for instruction\n",
progname, infile, lineno);
exit(1);
}
@@ -1484,8 +1464,7 @@ static int parse_cmdbits(OPCODE * op)
len = strlen(s);
if (len == 0) {
fprintf(stderr,
"%s: error at %s:%d: invalid bit specifier \"\"\n",
avrdude_message("%s: error at %s:%d: invalid bit specifier \"\"\n",
progname, infile, lineno);
exit(1);
}
@@ -1525,8 +1504,7 @@ static int parse_cmdbits(OPCODE * op)
op->bit[bitno].bitno = bitno % 8;
break;
default :
fprintf(stderr,
"%s: error at %s:%d: invalid bit specifier '%c'\n",
avrdude_message("%s: error at %s:%d: invalid bit specifier '%c'\n",
progname, infile, lineno, ch);
exit(1);
break;
@@ -1537,8 +1515,7 @@ static int parse_cmdbits(OPCODE * op)
q = &s[1];
op->bit[bitno].bitno = strtol(q, &e, 0);
if ((e == q)||(*e != 0)) {
fprintf(stderr,
"%s: error at %s:%d: can't parse bit number from \"%s\"\n",
avrdude_message("%s: error at %s:%d: can't parse bit number from \"%s\"\n",
progname, infile, lineno, q);
exit(1);
}
@@ -1546,8 +1523,7 @@ static int parse_cmdbits(OPCODE * op)
op->bit[bitno].value = 0;
}
else {
fprintf(stderr,
"%s: error at %s:%d: invalid bit specifier \"%s\"\n",
avrdude_message("%s: error at %s:%d: invalid bit specifier \"%s\"\n",
progname, infile, lineno, s);
exit(1);
}