avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] code restructuring - using C99 or not?


From: Joerg Wunsch
Subject: Re: [avrdude-dev] code restructuring - using C99 or not?
Date: Thu, 26 Jul 2012 11:30:43 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

As Axel Wachtler wrote:

> My intention would be to move the "if(verbose>SOMETHING)" into
> the macro itself, this would make the code easier to read.
> 
> PRINT(WARNING, "foo=%d\n", 42);

Sounds reasonable.

I'd call it MESSAGE() rather than PRINT().

> We should come up with severity list, e.g.
> 
>   ERROR   ... printed always
>   WARNING ... printed even if "quite" is set
>   INFO    ... normal print
>   DEBUG1  ... -v
>   DEBUG2  ... -vv
>   DEBUG3  ... -vvv
>   DEBUG4  ... -vvvv

Note that there's currently a distintion between -q and -qq.  The
latter makes it really quite regarding all informational messages,
while a single -q IMHO only silences the progress bar but still
displays some other messages.

> so I would prefer a callback function that gets a simple string and
> all the formatting is done in the central printing function.

It's OK, but I think the callback function should also get the
"severity" indication (rather than performing the yes/no decision
inside a macro or such), so it can decide by itself whether it has to
act upon the message, and how.  E.g., a GUI sitting on top of the
shared lib might opt to display error or warning messages in a popup,
informational messages in a status window, and log debugging messages
only internally, to be displayed upon request of the user (or to be
written in to a file).

This has also the advantage that the current global variables "quite"
and "verbose" could be made static to the existing main.c, and no
longer need to be known inside the library.
-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]