lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev patch for traversal


From: Klaus Weide
Subject: lynx-dev patch for traversal
Date: Mon, 30 Nov 1998 17:10:24 -0600 (CST)

This patch reverts the file-opening call which didn't work
back to previous behavior.  This is based on 2.8.1rel.2; I have
not checked whether the implementation of LYAppendToTxtFile etc.
has changed in the devel code so that my changes changes would be
unnecessary.  However, I would actually prefer to have everything
handled by just fopen, or a function that acts like it.  There is
IMO no good reason to apply paranoid permission checks for the
traversal files, it only gets in the way of legitimate uses.
For example the file permissions end up too restrictive, the normal
umask should apply; and links rejected by permission checks are
likely to be legitimate.

I have also made some changes to avoid repetitive code and to
get out of curses mode if an error occurs.  (I hope the use of
errno doesn't need to be ifdef'd for some systems.)


   Klaus


*** lynx2-8-1.orig/src/LYTraversal.c    Thu Aug  6 07:28:22 1998
--- lynx2-8-1/src/LYTraversal.c Mon Nov 30 16:55:16 1998
***************
*** 2,7 ****
--- 2,9 ----
  #include <LYGlobalDefs.h>
  #include <LYUtils.h>
  #include <LYSignal.h>
+ #include <LYClean.h>
+ #include <LYCurses.h>
  #include <LYTraversal.h>
  
  #include <LYexit.h>
***************
*** 9,34 ****
  
  /* routines to handle special traversal feature */
  
! PUBLIC BOOLEAN lookup ARGS1(char *,target)
  {
!     FILE *ifp;
!     char buffer[200], line[200];
  
!     if ((ifp = fopen(TRAVERSE_FILE,"r")) == NULL) {
!         if ((ifp = LYNewTxtFile(TRAVERSE_FILE)) == NULL) {
!             perror("unable to open or create a traversal file");
  #ifndef NOSIGHUP
!           (void) signal(SIGHUP, SIG_DFL);
  #endif /* NOSIGHUP */
!           (void) signal(SIGTERM, SIG_DFL);
  #ifndef VMS
!           (void) signal(SIGINT, SIG_DFL);
  #endif /* !VMS */
  #ifdef SIGTSTP
!           if (no_suspend)
!               (void) signal(SIGTSTP,SIG_DFL);
  #endif /* SIGTSTP */
!             exit(-1);
        } else {
              fclose(ifp);
              return(FALSE);
--- 11,54 ----
  
  /* routines to handle special traversal feature */
  
! PRIVATE void final_perror ARGS2(CONST char *,msg, BOOLEAN, clean_flag)
  {
!     int saved_errno = errno;
!     if (LYCursesON) {
!       if (clean_flag)
!           cleanup();
!       else
!           stop_curses();
!     }
!     errno = saved_errno;
!     perror(msg);
! }
  
! PRIVATE void exit_with_perror ARGS1(CONST char *,msg)
! {
!     final_perror(msg, TRUE);
  #ifndef NOSIGHUP
!     (void) signal(SIGHUP, SIG_DFL);
  #endif /* NOSIGHUP */
!     (void) signal(SIGTERM, SIG_DFL);
  #ifndef VMS
!     (void) signal(SIGINT, SIG_DFL);
  #endif /* !VMS */
  #ifdef SIGTSTP
!     if (no_suspend)
!       (void) signal(SIGTSTP,SIG_DFL);
  #endif /* SIGTSTP */
!     exit(-1);
! }
! 
! PUBLIC BOOLEAN lookup ARGS1(char *,target)
! {
!     FILE *ifp;
!     char buffer[200], line[200];
! 
!     if ((ifp = fopen(TRAVERSE_FILE,"r")) == NULL) {
!         if ((ifp = LYNewTxtFile(TRAVERSE_FILE)) == NULL) {
!             exit_with_perror("unable to open or create a traversal file");
        } else {
              fclose(ifp);
              return(FALSE);
***************
*** 54,72 ****
      FILE *ifp;
  
      if ((ifp = LYAppendToTxtFile(TRAVERSE_FILE)) == NULL) {
!       perror("unable to open traversal file");
! #ifndef NOSIGHUP
!       (void) signal(SIGHUP, SIG_DFL);
! #endif /* NOSIGHUP */
!       (void) signal(SIGTERM, SIG_DFL);
! #ifndef VMS
!       (void) signal(SIGINT, SIG_DFL);
! #endif /* !VMS */
! #ifdef SIGTSTP
!       if (no_suspend)
!           (void) signal(SIGTSTP,SIG_DFL);
! #endif /* SIGTSTP */
!       exit(-1);
      }
  
      fprintf(ifp,"%s\n",target);
--- 74,80 ----
      FILE *ifp;
  
      if ((ifp = LYAppendToTxtFile(TRAVERSE_FILE)) == NULL) {
!       exit_with_perror("unable to open traversal file");
      }
  
      fprintf(ifp,"%s\n",target);
***************
*** 79,98 ****
  
      FILE *ifp;
  
!     if ((ifp = LYAppendToTxtFile(TRAVERSE_FOUND_FILE)) == NULL) {
!       perror("unable to open traversal found file");
! #ifndef NOSIGHUP
!       (void) signal(SIGHUP, SIG_DFL);
! #endif /* NOSIGHUP */
!       (void) signal(SIGTERM, SIG_DFL);
! #ifndef VMS
!       (void) signal(SIGINT, SIG_DFL);
! #endif /* !VMS */
! #ifdef SIGTSTP
!       if (no_suspend)
!           (void) signal(SIGTSTP,SIG_DFL);
! #endif /* SIGTSTP */
!       exit(-1);
      }
  
      fprintf(ifp,"%s\t%s\n",fname, prev_link_name);
--- 87,94 ----
  
      FILE *ifp;
  
!     if ((ifp = fopen(TRAVERSE_FOUND_FILE,"a+")) == NULL) {
!       exit_with_perror("unable to open traversal found file");
      }
  
      fprintf(ifp,"%s\t%s\n",fname, prev_link_name);
***************
*** 109,115 ****
          return;
  
      if ((ifp = LYAppendToTxtFile(TRAVERSE_FILE)) == NULL) {
!         perror("unable to open traversal file");
        return;
      }
  
--- 105,111 ----
          return;
  
      if ((ifp = LYAppendToTxtFile(TRAVERSE_FILE)) == NULL) {
!         final_perror("unable to open traversal file", FALSE);
        return;
      }
  
***************
*** 128,147 ****
  
      FILE *ifp;
  
!     if ((ifp = LYAppendToTxtFile(TRAVERSE_REJECT_FILE)) == NULL) {
!       perror("unable to open reject file");
! #ifndef NOSIGHUP
!       (void) signal(SIGHUP, SIG_DFL);
! #endif /* NOSIGHUP */
!       (void) signal(SIGTERM, SIG_DFL);
! #ifndef VMS
!       (void) signal(SIGINT, SIG_DFL);
! #endif /* !VMS */
! #ifdef SIGTSTP
!       if (no_suspend)
!           (void) signal(SIGTSTP,SIG_DFL);
! #endif /* SIGTSTP */
!       exit(-1);
      }
  
      fprintf(ifp,"%s\n",target);
--- 124,131 ----
  
      FILE *ifp;
  
!     if ((ifp = fopen(TRAVERSE_REJECT_FILE,"a+")) == NULL) {
!       exit_with_perror("unable to open reject file");
      }
  
      fprintf(ifp,"%s\n",target);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]