#1 Backlight, parser, client functions, etc

closed-accepted
5
2001-09-27
2001-09-18
No

David Douthitt has been working hard on cleaning up and
enhancing LCDproc. He's submitted several patches
(thankfully they're cummulative :). Here are his
comments about them (chronological order):

---
Also, I didn't like the way that LCDd opens up port
13666 to the world;
attached is a patch which also makes it easy to add a
port/address
option.
---

* LCDd now uses getopt_long(3)
* Refuses to "load" driver named "base"
* Help display shows valid available drivers
* Text Driver now has a help screen and exits properly
when options are
given
* Better bombproofing

---
* Development code can be seen for using tcpwrappers --
gleaned from
initial viewing of hosts_access(3).

* sprintf has been replaced with snprintf in the server
entirely (though
not in any of the drivers).

I also used sprintf(x, sizeof(x), "...") instead of
sprintf(x, 256,
"...") as the bugtraq posting suggested: sizeof() is, I
believe, a macro
and thus generates a fixed number at compile time, and
also will
automatically accomodate larger buffers without
programmer intervention
(except to recompile).

---
Applying this patch to 0.4.1 should be fine. It
replaces blindly all
sprintf with snprintf in the server, but mainly
replaces sections of
code in the MtxOrb driver (MtxOrb.c) like so:

sprintf(out, "%cV%c", 254, 0);
write(fd, out, 3);

...with this...

write(fd, "\x0FEV\x000", 3);

In some cases, this results in out[] becoming
unnecessary; many times it
removes the need for a sprintf() call.

---

This patch should result in a basically working LCDd.

MtxOrb.c (the Matrix Orbital driver) is heavily
modified. There are a
lot of comments now sprinkled within the code; some
contain questions
and ideas. The code to analyze the options was heavily
modified, with
most "manipulations" (such as analyzing options and
setting options)
being shifted to separate functions. A conversion
(again) to getopts(3)
is in the future.

There is a new command available in the driver
structure (getinfo) and
the MtxOrb driver takes advantage of it.

There is also a new command for the server (in
client_functions.c) to
output this string.

Unfortunately, I can't seem to be able to get any
output from the
display in this program... So until some kind somebody
has different
ideas, the "info" returned will only display the
current driver name.

I also took out the "bye" when the daemon quits - it
was showing up in
triples and even on the display at times.

I looked at input.c, but couldn't make it work for me.
I did try
setting the keys differently for the LK202-25 - it
generates keys for A
F K I and N (with two missing keys?!).

A - right arrow
F - down
K - left
I - up

N - F2
? - F1
? - Enter

Anyone know what those other keys ought to be?

Also, shouldn't "backlight" support be relegated to the
drivers? Some
drivers might not support the backlight.

Many of the changes I make are just designed to make it
easier to
maintain the code and to understand what is happening.

---
The biggest things I did here was to go through
client_functions.c,
cleaning out all the argument count testing code, as
well as returning
the usage of a command if no arguments are given.

The big change with the argument testing code was that
now, there is,
wherever possible, a SINGLE test to divide the bad
argument counts from
the valid argument counts - which is faster.

It would also appear that there were bugs in this code;
argc counts all
argument entries, including argv[0]. Some code also
appeared to have
been cut and pasted, but not fixed up.

I also changed the exit code so that stdin, stdout, and
stderr are not
closed (as requested in the code). I also changed
read_from_client to
test errno; however, errno appears to often have the
value EAGAIN
("Resource temporarily unavailable") so I tested for
that. I suspect
that this is from other file descriptors, and not from
the currently
connected client.

---
client_set_func seemed to have some errors; I gave it a
thorough
debugging.

I updated MtxOrb.c some; I mucked with input.c. My
keyboard on my
LK202-25 gives a funky set of keys; it is "codified" in
input.c - change
at will...

The biggest change was parse.c; I changed it to use
pointers and do a
scan character by character. I also added the
following enhancements:

1. Now a '#' in the first position is ignored as a comment.
2. Now excess whitespace should be handled (don't know
if it was
previously...)
2a. Also, a line of ONLY whitespace is handled
correctly (i.e.,
ignored)
2b. I think, too, that an EMPTY line will be handled
correctly...
3. Tabs are *NOT* considered whitespace; neither is a
return.

---
Whew! Thanks David for all these contributions!

Discussion

  • William W. Ferrell

    • status: open --> closed
     
  • William W. Ferrell

    • status: closed --> closed-accepted
     
  • William W. Ferrell

    Logged In: YES
    user_id=839

    These have been committed via CVS.

     

Log in to post a comment.