mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-09-27 14:35:27 +00:00
main.c, pgm.c, pgm.h: Add setup and teardown hooks to the programmer
definition. If present, call the setup hook immediately after finding the respective programmer object, and schedule the teardown hook to be called upon exit. This allows the programmer implementation to dynamically allocate private programmer data. avr910.c, butterfly.c, jtagmkI.c, jtagmkII.c, stk500v2.c, usbasp.c, usbtiny.c: Convert static programmer data into dynamically allocated data. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@764 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
17
main.c
17
main.c
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
||||
* Copyright (C) 2000-2005 Brian S. Dean <bsd@bsdhome.com>
|
||||
* Copyright 2007 Joerg Wunsch <j@uriah.heep.sax.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -74,6 +75,8 @@ static LISTID updates;
|
||||
|
||||
static LISTID extended_params;
|
||||
|
||||
static PROGRAMMER * pgm;
|
||||
|
||||
/*
|
||||
* global options
|
||||
*/
|
||||
@@ -222,6 +225,12 @@ static void list_parts(FILE * f, const char *prefix, LISTID avrparts)
|
||||
walk_avrparts(avrparts, list_avrparts_callback, &c);
|
||||
}
|
||||
|
||||
static void exithook(void)
|
||||
{
|
||||
if (pgm->teardown)
|
||||
pgm->teardown(pgm);
|
||||
}
|
||||
|
||||
/*
|
||||
* main routine
|
||||
*/
|
||||
@@ -238,7 +247,6 @@ int main(int argc, char * argv [])
|
||||
struct stat sb;
|
||||
UPDATE * upd;
|
||||
LNODEID * ln;
|
||||
PROGRAMMER * pgm;
|
||||
|
||||
|
||||
/* options / operating mode variables */
|
||||
@@ -636,6 +644,13 @@ int main(int argc, char * argv [])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (pgm->setup) {
|
||||
pgm->setup(pgm);
|
||||
}
|
||||
if (pgm->teardown) {
|
||||
atexit(exithook);
|
||||
}
|
||||
|
||||
if (lsize(extended_params) > 0) {
|
||||
if (pgm->parseextparams == NULL) {
|
||||
fprintf(stderr,
|
||||
|
Reference in New Issue
Block a user