On Jan 18, 2008 12:41 AM, Bernhard Fischer <[EMAIL PROTECTED]> wrote:
> On Wed, Jan 16, 2008 at 10:02:10PM -0800, Steve Bradshaw wrote:
...
> >
> >diff -ur busybox-1.8.2.orig/miscutils/microcom.c 
> >busybox-1.8.2.new/miscutils/microcom.c
> >--- busybox-1.8.2.orig/miscutils/microcom.c    2007-11-09 17:40:53.000000000 
> >-0800
> >+++ busybox-1.8.2.new/miscutils/microcom.c     2008-01-16 18:44:44.715294000 
> >-0800
> >@@ -9,19 +9,30 @@
> >  */
> > #include "libbb.h"
> >
> >+static volatile int gotSig;
>
> Should this be in globals?

I'm not sure what you mean.  It's only used
in this file.  Are you suggesting it should be
put in a lib func?

> >+
> >+static void
> >+sigCatch(int signo)
> >+{
> >+      gotSig = signo;
> >+}
> >+

> >       int len;
> >+      int usr_is_tty;
>
> bool or smalluint is smaller?

Yes, I can make it a bool.

...
> >
> >-      // open device
> >+      // Open device, save current tty settings
> >       sfd = open(argv[0], O_RDWR);
>
> open_or_warn()

Yes, open_or_warn() will work.

...
> >       while (1) {
> >               int i;
> >               safe_poll(pfd, 2, -1);
> >               for (i = 0; i < 2; ++i) {
> >+                      if (gotSig)
> >+                              goto cleanup_and_exit;
> >                       if (pfd[i].revents & POLLIN) {
> >-                              len = read(pfd[i].fd, bb_common_bufsiz1, 
> >COMMON_BUFSIZE);
> >-                              if (len > 0) {
> >-                                      if (!i && 24 == bb_common_bufsiz1[0])
> >-                                              goto done; // ^X exits
> >-                                      write(pfd[1-i].fd, bb_common_bufsiz1, 
> >len);
> >+                              char *buf = bb_common_bufsiz1;
> >+                              if ((len = read(pfd[i].fd, buf, 
> >COMMON_BUFSIZE)) <= 0)
> >+                                      goto cleanup_and_exit;
> >+                              if (!i) {           // Process stdin:
> >+ again:
> >+                                      if (24 == buf[0])   // ^X exits
> >+                                              goto cleanup_and_exit;
> >+                                      if (0  == buf[0]) { // ^@ sends Break
> >+                                              tcsendbreak(outfd[i], 0);
> >+                                              if (--len <= 0)
> >+                                                      continue;
> >+                                              buf++;
> >+                                              goto again;     // next byte
> >+                                      }
> >                               }
>
> Can you reuse some libbb func for (parts of) the block above?

I don't think so, but I'm not very familiar with what's available.
Any idea's?

Steve
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to