Something I always wanted to do: replace all those private "extern"

declarations in each file by a central header file "avrdude.h".


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@721 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2007-01-24 21:07:54 +00:00
parent 2c6b2309d5
commit 1cae809b9b
30 changed files with 106 additions and 98 deletions

View File

@ -1,3 +1,36 @@
2007-01-13 Joerg Wunsch <j@uriah.heep.sax.de>
Move all "extern" declarations into a centreal header file.
* Makefile.am: Add new avrdude.h.
* avrdude.h: New file.
* avr.c: Replace private extern decl's by #include "avrdude.h".
* avr910.c: (Ditto.)
* avrpart.c: (Ditto.)
* bitbang.c: (Ditto.)
* butterfly.c: (Ditto.)
* config.c: (Ditto.)
* config_gram.y: (Ditto.)
* fileio.c: (Ditto.)
* jtagmkI.c: (Ditto.)
* jtagmkII.c: (Ditto.)
* lexer.l: (Ditto.)
* main.c: (Ditto.)
* par.c: (Ditto.)
* pgm.c: (Ditto.)
* ppi.c: (Ditto.)
* ppiwin.c: (Ditto.)
* ser_avrdoper.c: (Ditto.)
* ser_posix.c: (Ditto.)
* ser_win32.c: (Ditto.)
* serbb_posix.c: (Ditto.)
* serbb_win32.c: (Ditto.)
* stk500.c: (Ditto.)
* stk500generic.c: (Ditto.)
* stk500v2.c: (Ditto.)
* term.c: (Ditto.)
* usb_libusb.c: (Ditto.)
* usbasp.c: (Ditto.)
2007-01-13 Joerg Wunsch <j@uriah.heep.sax.de>
* avrdude.conf.in (ATmega8): Bump the delay values for flash

View File

@ -73,6 +73,7 @@ avrdude_SOURCES = \
avr.h \
avr910.c \
avr910.h \
avrdude.h \
avrpart.c \
avrpart.h \
bitbang.c \

9
avr.c
View File

@ -28,6 +28,7 @@
#include <sys/time.h>
#include <time.h>
#include "avrdude.h"
#include "avr.h"
#include "lists.h"
@ -37,14 +38,6 @@
#define DEBUG 0
extern char * progname;
extern char progbuf[];
extern PROGRAMMER * pgm;
extern int do_cycles;
int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value)
{

View File

@ -33,15 +33,13 @@
#include <sys/time.h>
#include <unistd.h>
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "avr910.h"
#include "serial.h"
extern char * progname;
extern int do_cycles;
extern int ovsigck;
static char has_auto_incr_addr;

33
avrdude.h Normal file
View File

@ -0,0 +1,33 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2007 Joerg Wunsch
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Id$ */
#ifndef avrdude_h
#define avrdude_h
extern char * progname; /* name of program, for messages */
extern char progbuf[]; /* spaces same length as progname */
extern int do_cycles; /* track erase-rewrite cycles (-y) */
extern int ovsigck; /* override signature check (-F) */
extern int verbose; /* verbosity level (-v, -vv, ...) */
extern int quell_progress; /* quiteness level (-q, -qq) */
#endif

View File

@ -24,12 +24,10 @@
#include <stdlib.h>
#include <string.h>
#include "avrdude.h"
#include "avrpart.h"
#include "pindefs.h"
extern char * progname;
/***
*** Elementary functions dealing with OPCODE structures
***/

View File

@ -33,16 +33,13 @@
# include <sys/time.h>
#endif
#include "avrdude.h"
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "par.h"
#include "serbb.h"
extern char * progname;
extern int do_cycles;
extern int verbose;
static int delay_decrement;
#if !defined(WIN32NATIVE)

View File

@ -44,14 +44,12 @@
#include <errno.h>
#include <ctype.h>
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "butterfly.h"
#include "serial.h"
extern char * progname;
extern int do_cycles;
static char has_auto_incr_addr;
static unsigned buffersize = 0;

View File

@ -45,8 +45,10 @@ AVRMEM * current_mem;
LISTID part_list;
LISTID programmers;
int lineno = 0;
char * infile = NULL;
int lineno;
char * infile;
extern char * yytext;
#define DEBUG 0
@ -261,8 +263,6 @@ void print_token(TOKEN * tkn)
void pyytext(void)
{
#if DEBUG
extern char * yytext;
fprintf(stderr, "TOKEN: \"%s\"\n", yytext);
#endif
}

View File

@ -27,6 +27,8 @@
#include <string.h>
#include <math.h>
#include "avrdude.h"
#include "config.h"
#include "lists.h"
#include "par.h"
@ -49,8 +51,6 @@
( *(_lasts) = strtok( (_s), (_sep) ) )
#endif
extern char * progname;
int yylex(void);
int yyerror(char * errmsg);

View File

@ -28,6 +28,7 @@
#include <errno.h>
#include <ctype.h>
#include "avrdude.h"
#include "avr.h"
#include "fileio.h"
@ -46,10 +47,6 @@ struct ihexrec {
};
extern char * progname;
extern char progbuf[];
extern int quell_progress;
int b2ihex(unsigned char * inbuf, int bufsize,
int recsize, int startaddr,
char * outfile, FILE * outf);

View File

@ -33,14 +33,12 @@
#include <sys/time.h>
#include <time.h>
#include "avrdude.h"
#include "avr.h"
#include "crc16.h"
#include "pgm.h"
#include "jtagmkI_private.h"
#include "serial.h"
extern int verbose;
extern char * progname;
extern int do_cycles;
/*
* XXX There should really be a programmer-specific private data

View File

@ -41,6 +41,7 @@
#include <sys/time.h>
#include <time.h>
#include "avrdude.h"
#include "avr.h"
#include "crc16.h"
#include "pgm.h"
@ -50,10 +51,6 @@
#include "usbdevs.h"
extern int verbose;
extern char * progname;
extern int do_cycles;
/*
* XXX There should really be a programmer-specific private data
* pointer in struct PROGRAMMER.

View File

@ -29,13 +29,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "avrdude.h"
#include "config.h"
#include "config_gram.h"
#include "lists.h"
extern int lineno;
extern char * infile;
void pyytext(void);
#define YY_NO_UNPUT

6
main.c
View File

@ -74,9 +74,6 @@ typedef struct update_t {
/* Get VERSION from ac_cfg.h */
char * version = VERSION;
int verbose; /* verbose output */
int quell_progress; /* un-verebose output */
int ovsigck; /* 1=override sig check, 0=don't */
char * progname;
char progbuf[PATH_MAX]; /* temporary buffer of spaces the same
length as progname; used for lining up
@ -90,6 +87,9 @@ LISTID updates;
* global options
*/
int do_cycles; /* track erase-rewrite cycles */
int verbose; /* verbose output */
int quell_progress; /* un-verebose output */
int ovsigck; /* 1=override sig check, 0=don't */
/*

5
par.c
View File

@ -36,16 +36,13 @@
# include "solaris_ecpp.h"
#endif
#include "avrdude.h"
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "ppi.h"
#include "bitbang.h"
extern char * progname;
extern int do_cycles;
extern int verbose;
#if HAVE_PARPORT
struct ppipins_t {

3
pgm.c
View File

@ -25,10 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include "avrdude.h"
#include "pgm.h"
extern char * progname;
static int pgm_default_2 (struct programmer_t *, AVRPART *);
static int pgm_default_3 (struct programmer_t * pgm, AVRPART * p, AVRMEM * mem,
unsigned long addr, unsigned char * value);

3
ppi.c
View File

@ -41,13 +41,12 @@
# include "solaris_ecpp.h"
#endif
#include "avrdude.h"
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "ppi.h"
extern char * progname;
enum {
PPI_READ,
PPI_WRITE,

View File

@ -43,13 +43,11 @@ reg = register as defined in an enum in ppi.h. This must be converted
#include <windows.h>
#include <sys/time.h>
#include <windows.h>
#include "avrdude.h"
#include "serial.h"
#include "ppi.h"
extern char *progname;
#define DEVICE_LPT1 "lpt1"
#define DEVICE_LPT2 "lpt2"
#define DEVICE_LPT3 "lpt3"

View File

@ -32,6 +32,7 @@
#include <stdio.h>
#include <string.h>
#include "avrdude.h"
#include "serial.h"
/* ------------------------------------------------------------------------ */
@ -53,9 +54,6 @@
#define USB_VENDOR_ID 0x16c0
#define USB_PRODUCT_ID 0x05df
extern char *progname;
extern int verbose;
static int reportDataSizes[4] = {13, 29, 61, 125};
static unsigned char avrdoperRxBuffer[280]; /* buffer for receive data */

View File

@ -42,11 +42,9 @@
#include <termios.h>
#include <unistd.h>
#include "avrdude.h"
#include "serial.h"
extern char *progname;
extern int verbose;
long serial_recv_timeout = 5000; /* ms */
struct baud_mapping {

View File

@ -29,10 +29,9 @@
#include <windows.h>
#include <stdio.h>
#include <ctype.h> /* for isprint */
#include "serial.h"
extern char *progname;
extern int verbose;
#include "avrdude.h"
#include "serial.h"
long serial_recv_timeout = 5000; /* ms */

View File

@ -37,6 +37,7 @@
#include <sys/ioctl.h>
#include <termios.h>
#include "avrdude.h"
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
@ -44,8 +45,7 @@
#undef DEBUG
extern char *progname;
struct termios oldmode;
static struct termios oldmode;
/*
serial port/pin mapping

View File

@ -32,14 +32,12 @@
#include <windows.h>
#include <stdio.h>
#include "avrdude.h"
#include "avr.h"
#include "pindefs.h"
#include "pgm.h"
#include "bitbang.h"
extern char *progname;
extern int verbose;
/* cached status lines */
static int dtr, rts, txd;

View File

@ -36,6 +36,7 @@
#include <errno.h>
#include <unistd.h>
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "stk500_private.h"
@ -43,11 +44,6 @@
#define STK500_XTAL 7372800U
extern int verbose;
extern char * progname;
extern int do_cycles;
static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value);
static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value);
static void stk500_print_parms1(PROGRAMMER * pgm, char * p);

View File

@ -32,12 +32,11 @@
#include <stdio.h>
#include <string.h>
#include "avrdude.h"
#include "pgm.h"
#include "stk500.h"
#include "stk500v2.h"
extern char *progname;
static int stk500generic_open(PROGRAMMER * pgm, char * port)
{
stk500_initpgm(pgm);

View File

@ -47,6 +47,7 @@
#include <sys/time.h>
#include <time.h>
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "stk500_private.h" // temp until all code converted
@ -85,10 +86,6 @@ enum hvmode
};
extern int verbose;
extern char * progname;
extern int do_cycles;
/*
* See stk500pp_read_byte() for an explanation of the flash and
* EEPROM page caches.

7
term.c
View File

@ -34,6 +34,7 @@
#endif
#endif
#include "avrdude.h"
#include "avr.h"
#include "config.h"
#include "lists.h"
@ -41,12 +42,6 @@
#include "pindefs.h"
#include "ppi.h"
extern char * progname;
extern char progbuf[];
extern PROGRAMMER * pgm;
struct command {
char * name;
int (*func)(PROGRAMMER * pgm, struct avrpart * p, int argc, char *argv[]);

View File

@ -38,12 +38,10 @@
#include <usb.h>
#include "avrdude.h"
#include "serial.h"
#include "usbdevs.h"
extern char *progname;
extern int verbose;
static char usbbuf[USBDEV_MAX_XFER];
static int buflen = -1, bufptr;

View File

@ -33,6 +33,7 @@
#include <sys/time.h>
#include <unistd.h>
#include "avrdude.h"
#include "avr.h"
#include "pgm.h"
#include "usbasp.h"
@ -40,10 +41,6 @@
#ifdef HAVE_LIBUSB
#include <usb.h>
extern int verbose;
extern char * progname;
extern int do_cycles;
static usb_dev_handle *usbhandle;
/*
@ -426,8 +423,6 @@ void usbasp_initpgm(PROGRAMMER * pgm)
#else /* HAVE_LIBUSB */
extern char * progname;
static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
{
fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",