[U-Boot] [PATCH 2/3] tools: mkimage (type=kwbimage) kirkwood boot image support
Wolfgang Denk
wd at denx.de
Mon Jul 20 16:57:09 CEST 2009
Dear Prafulla Wadaskar,
In message <73173D32E9439E4ABB5151606C3E19E202DDF272E2 at SC-VEXCH1.marvell.com> you wrote:
>
> > > + lineno++;
> > > + if (!(line[0] != '#' && strlen(line) != 1))
> > > + continue;
> >
> > This is a bit simple-minded. This will for example fail on
> > DOS-formatted files, and for lines that contain only white
> > space (which still look "empty" to most users and are thus
> > hard to spot).
> To take care of Dos formatted file I should use "strlen(line) <= 1" right
Hm...
Normally the use of lex (and eventually yacc) is recommended if you
need a parser - writing parsers in C is a typical "programming" task
(see definition in signature below :-)
If you have an extremely simple syntax, you might for example proceed
like this:
1) drop all lines starting with '#' as comment lines.
2) use strtok_r() to split your lines of input into white-space
separated tokens.
3) drop all lines with zero tokens (= empty lines)
4) process the rest
[See example in the strtok()/strtok_r() man page).
> As explained in doc.README.kwimage,
> any other line apart from above will be considered as valid configuration l> ine.
> This is bare minimal parsing provided here which is sufficient
...
> > Hmm... it seems you add only image creation code. But "mkimage -l"
> > should work on such an image, too. And "imls" in U-Boot
> > should be working, too.
> Well I will disable other generic mkimage options including -l for kwbimage ;-)
This makes little sense to me. When we have one command to build an
image, I definitely want to have a command to check and display the
contents of an image, too, and/or to verify it's integrity.
> Can we add this in second part which is not required too?
> For me great thing is that we can support kwimage generation through mkimage.
I understand your position. I guess you agree that _full_ support
(i.e. including the ability to check and list and image, both on the
host and on the target) would be even better, and more in line with
existing U-Boot code?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PROGRAM - n. A magic spell cast over a computer allowing it to turn
one's input into error messages.
v. tr. - To engage in a pastime similar to banging one's head against
a wall, but with fewer opportunities for reward.
More information about the U-Boot
mailing list