diff -rc stunnel-4.15.old/src/network.c stunnel-4.15/src/network.c
*** stunnel-4.15.old/src/network.c	2006-03-01 15:41:08.000000000 +0100
--- stunnel-4.15/src/network.c	2006-04-13 17:44:10.000000000 +0200
***************
*** 42,50 ****
  static void client_status(void); /* dead children detected */
  #endif
  #endif /* !defined(USE_WIN32) */
- 
  static void setnonblock(int, unsigned long);
  
  #ifdef USE_POLL
  
  void s_poll_zero(s_poll_set *fds) {
--- 42,51 ----
  static void client_status(void); /* dead children detected */
  #endif
  #endif /* !defined(USE_WIN32) */
  static void setnonblock(int, unsigned long);
  
+ /**************************************** s_poll functions */
+ 
  #ifdef USE_POLL
  
  void s_poll_zero(s_poll_set *fds) {
***************
*** 338,343 ****
--- 339,346 ----
      errno=save_errno;
  }
  
+ /**************************************** signal pipe */
+ 
  int signal_pipe_init(void) {
      if(pipe(signal_pipe)) {
          ioerror("pipe");
***************
*** 417,422 ****
--- 420,427 ----
  
  #endif /* !defined USE_WIN32 */
  
+ /**************************************** fd management */
+ 
  int alloc_fd(int sock) {
  #ifndef USE_WIN32
      if(!max_fds || sock>=max_fds) {
***************
*** 486,492 ****
      return 0; /* OK */
  }
  
! void write_blocking(CLI *c, int fd, u8 *ptr, int len) {
          /* simulate a blocking write */
      s_poll_set fds;
      int num;
--- 491,499 ----
      return 0; /* OK */
  }
  
! /**************************************** simulate blocking I/O */
! 
! void write_blocking(CLI *c, int fd, void *ptr, int len) {
          /* simulate a blocking write */
      s_poll_set fds;
      int num;
***************
*** 513,524 ****
              sockerror("writesocket (write_blocking)");
              longjmp(c->err, 1);
          }
!         ptr+=num;
          len-=num;
      }
  }
  
! void read_blocking(CLI *c, int fd, u8 *ptr, int len) {
          /* simulate a blocking read */
      s_poll_set fds;
      int num;
--- 520,531 ----
              sockerror("writesocket (write_blocking)");
              longjmp(c->err, 1);
          }
!         ptr=(u8 *)ptr+num;
          len-=num;
      }
  }
  
! void read_blocking(CLI *c, int fd, void *ptr, int len) {
          /* simulate a blocking read */
      s_poll_set fds;
      int num;
***************
*** 548,575 ****
              s_log(LOG_ERR, "Unexpected socket close (read_blocking)");
              longjmp(c->err, 1);
          }
!         ptr+=num;
          len-=num;
      }
  }
  
! void fdputline(CLI *c, int fd, char *line) {
!     char logline[STRLEN];
      const char crlf[]="\r\n";
  
!     if(strlen(line)+2>=STRLEN) { /* 2 for crlf */
!         s_log(LOG_ERR, "Line too long in fdputline");
!         longjmp(c->err, 1);
!     }
!     safecopy(logline, line); /* the line without crlf */
!     safeconcat(line, crlf);
!     write_blocking(c, fd, line, strlen(line));
!     safestring(logline);
!     s_log(LOG_DEBUG, " -> %s", logline);
  }
  
  void fdgetline(CLI *c, int fd, char *line) {
!     char logline[STRLEN];
      s_poll_set fds;
      int ptr;
  
--- 555,580 ----
              s_log(LOG_ERR, "Unexpected socket close (read_blocking)");
              longjmp(c->err, 1);
          }
!         ptr=(u8 *)ptr+num;
          len-=num;
      }
  }
  
! void fdputline(CLI *c, int fd, const char *line) {
!     char tmpline[STRLEN];
      const char crlf[]="\r\n";
  
!     safecopy(tmpline, line);
!     safeconcat(tmpline, crlf);
!     write_blocking(c, fd, tmpline, strlen(tmpline));
! 
!     safecopy(tmpline, line);
!     safestring(tmpline);
!     s_log(LOG_DEBUG, " -> %s", tmpline);
  }
  
  void fdgetline(CLI *c, int fd, char *line) {
!     char tmpline[STRLEN];
      s_poll_set fds;
      int ptr;
  
***************
*** 609,617 ****
          }
      }
      line[ptr]='\0';
!     safecopy(logline, line);
!     safestring(logline);
!     s_log(LOG_DEBUG, " <- %s", logline);
  }
  
  int fdprintf(CLI *c, int fd, const char *format, ...) {
--- 614,622 ----
          }
      }
      line[ptr]='\0';
!     safecopy(tmpline, line);
!     safestring(tmpline);
!     s_log(LOG_DEBUG, " <- %s", tmpline);
  }
  
  int fdprintf(CLI *c, int fd, const char *format, ...) {
diff -rc stunnel-4.15.old/src/prototypes.h stunnel-4.15/src/prototypes.h
*** stunnel-4.15.old/src/prototypes.h	2006-03-01 15:41:08.000000000 +0100
--- stunnel-4.15/src/prototypes.h	2006-04-13 17:44:10.000000000 +0200
***************
*** 289,297 ****
  
  /**************************************** Prototypes for network.c */
  
! void write_blocking(CLI *, int fd, u8 *, int);
! void read_blocking(CLI *, int fd, u8 *, int);
! void fdputline(CLI *, int, char *);
  void fdgetline(CLI *, int, char *);
  /* descriptor versions of fprintf/fscanf */
  int fdprintf(CLI *, int, const char *, ...)
--- 289,297 ----
  
  /**************************************** Prototypes for network.c */
  
! void write_blocking(CLI *, int fd, void *, int);
! void read_blocking(CLI *, int fd, void *, int);
! void fdputline(CLI *, int, const char *);
  void fdgetline(CLI *, int, char *);
  /* descriptor versions of fprintf/fscanf */
  int fdprintf(CLI *, int, const char *, ...)
