From cdd82f5dfcf4d2f9a7403703cd6ac0e041f9f670 Mon Sep 17 00:00:00 2001 From: hinni Date: Sun, 30 Nov 2003 16:49:00 +0000 Subject: [PATCH] *avrpart.c,main.c: Moved list_parts() and locate_part() from main.c to avrpart.c *avrpart.h: Added prototypes for list_parts() and locate_part() git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@389 81a1dc3b-b13d-400b-aceb-764788c761c2 --- avrpart.c | 37 +++++++++++++++++++++++++++++++++++++ avrpart.h | 2 ++ main.c | 43 +++---------------------------------------- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/avrpart.c b/avrpart.c index eb6ec3d9..ea761000 100644 --- a/avrpart.c +++ b/avrpart.c @@ -397,6 +397,43 @@ AVRPART * avr_dup_part(AVRPART * d) } +AVRPART * locate_part(LISTID parts, char * partdesc) +{ + LNODEID ln1; + AVRPART * p = NULL; + int found; + + found = 0; + + for (ln1=lfirst(parts); ln1 && !found; ln1=lnext(ln1)) { + p = ldata(ln1); + if ((strcasecmp(partdesc, p->id) == 0) || + (strcasecmp(partdesc, p->desc) == 0)) + found = 1; + } + + if (found) + return p; + + return NULL; +} + + +void list_parts(FILE * f, char * prefix, LISTID parts) +{ + LNODEID ln1; + AVRPART * p; + + for (ln1=lfirst(parts); ln1; ln1=lnext(ln1)) { + p = ldata(ln1); + fprintf(f, "%s%-4s = %-15s [%s:%d]\n", + prefix, p->id, p->desc, p->config_file, p->lineno); + } + + return; +} + + char * reset_disp_str(int r) { switch (r) { diff --git a/avrpart.h b/avrpart.h index ea501f80..96f755d7 100644 --- a/avrpart.h +++ b/avrpart.h @@ -134,6 +134,8 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type, /* Functions for AVRPART structures */ AVRPART * avr_new_part(void); AVRPART * avr_dup_part(AVRPART * d); +AVRPART * locate_part(LISTID parts, char * partdesc); +void list_parts(FILE * f, char * prefix, LISTID parts); void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose); #endif diff --git a/main.c b/main.c index c8015fb8..5d37afe8 100644 --- a/main.c +++ b/main.c @@ -227,43 +227,6 @@ PROGRAMMER * locate_programmer(LISTID programmers, char * configid) return NULL; } - -AVRPART * locate_part(LISTID parts, char * partdesc) -{ - LNODEID ln1; - AVRPART * p = NULL; - int found; - - found = 0; - - for (ln1=lfirst(parts); ln1 && !found; ln1=lnext(ln1)) { - p = ldata(ln1); - if ((strcasecmp(partdesc, p->id) == 0) || - (strcasecmp(partdesc, p->desc) == 0)) - found = 1; - } - - if (found) - return p; - - return NULL; -} - - -void list_parts(FILE * f, char * prefix, LISTID parts) -{ - LNODEID ln1; - AVRPART * p; - - for (ln1=lfirst(parts); ln1; ln1=lnext(ln1)) { - p = ldata(ln1); - fprintf(f, "%s%-4s = %-15s [%s:%d]\n", - prefix, p->id, p->desc, p->config_file, p->lineno); - } - - return; -} - void list_programmers(FILE * f, char * prefix, LISTID programmers) { LNODEID ln1; @@ -271,8 +234,8 @@ void list_programmers(FILE * f, char * prefix, LISTID programmers) for (ln1=lfirst(programmers); ln1; ln1=lnext(ln1)) { p = ldata(ln1); - fprintf(f, "%s%-8s = %-30s [%s:%d]\n", - prefix, (char *)ldata(lfirst(p->id)), p->desc, + fprintf(f, "%s%-8s = %-30s [%s:%d]\n", + prefix, (char *)ldata(lfirst(p->id)), p->desc, p->config_file, p->lineno); } @@ -287,7 +250,7 @@ static FP_UpdateProgress update_progress; The first call of report_progress() should look like this (for a write op): - report_progress (0, 1, "Writing"); + report_progress (0, 1, "Writing"); Then hdr should be passed NULL on subsequent calls while the operation is progressing. Once the operation is complete, a final call should be made as