diff options
author | Willy Tarreau <w@1wt.eu> | 2006-07-16 14:53:39 +0200 |
---|---|---|
committer | Willy Tarreau <willy@wtap.(none)> | 2006-07-26 11:51:24 +0200 |
commit | cd97a35e24dcb6728b06f9974ed9ba49d07227b8 (patch) | |
tree | 7dd9977f67ec52b4853cdd6f6b104d533c801853 /lcd | |
parent | [RELEASE] flxutils-0.1.22 (diff) | |
download | flxutils-cd97a35e24dcb6728b06f9974ed9ba49d07227b8.tar.xz |
[RELEASE] flxutils-0.1.23v0.1.23
Diffstat (limited to 'lcd')
-rw-r--r-- | lcd/Makefile | 9 | ||||
-rw-r--r-- | lcd/lcdtee.c | 21 | ||||
-rw-r--r-- | lcd/lcdwrite.c | 34 |
3 files changed, 64 insertions, 0 deletions
diff --git a/lcd/Makefile b/lcd/Makefile new file mode 100644 index 0000000..06e0926 --- /dev/null +++ b/lcd/Makefile @@ -0,0 +1,9 @@ +OBJS=lcdwrite lcdtee +include ../include/rules.make +CFLAGS+=-fomit-frame-pointer + +%: %.c + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $< + strip -R .comment -R .note $@ + objdump -h $@ | grep -q '\.data[ ]*00000000' && strip -R .data $@ || true + sstrip $@ diff --git a/lcd/lcdtee.c b/lcd/lcdtee.c new file mode 100644 index 0000000..2cab2ef --- /dev/null +++ b/lcd/lcdtee.c @@ -0,0 +1,21 @@ +/* simply write all args to /dev/lcd, and don't complain if it doesn't work */ +#include <sys/fcntl.h> + +main(int argc, char **argv) { + int fd; + char buf[1024]; + int len; + + fd = open("/dev/lcd", O_WRONLY); + + while ((len = read(0, buf, sizeof(buf))) > 0) { + write(1, buf, len); + if (fd > 0) + write(fd, buf, len); + } + + if (fd > 0) + close(fd); + return 0; +} + diff --git a/lcd/lcdwrite.c b/lcd/lcdwrite.c new file mode 100644 index 0000000..5f86c46 --- /dev/null +++ b/lcd/lcdwrite.c @@ -0,0 +1,34 @@ +/* simply write all args to /dev/lcd, and don't complain if it doesn't work */ +#include <sys/fcntl.h> + +main(int argc, char **argv) { + int fd; + char buf[1024]; + int len; + + + if ((fd = open("/dev/lcd", O_WRONLY)) == -1) + return 0; + + + if (--argc == 0) { + while ((len = read(0, buf, sizeof(buf))) > 0) + write(fd, buf, len); + } + else { + argv++; + + while (argc--) { + len = strlen(*argv); + if (argc) /* still other args */ + argv[0][len++]=' '; /* add a delimitor */ + else + argv[0][len++]='\n'; /* end with a newline */ + write(fd, *argv, len); + argv++; + } + } + close(fd); + return 0; +} + |