[BACK]Return to cgi.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/cgi.c between version 1.53 and 1.54

version 1.53, 2014/07/09 08:53:28 version 1.54, 2014/07/09 09:19:03
Line 20 
Line 20 
 #endif  #endif
   
 #include <ctype.h>  #include <ctype.h>
 #include <dirent.h>  
 #include <fcntl.h>  #include <fcntl.h>
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
Line 77  static void   http_parse(struct req *, char *);
Line 76  static void   http_parse(struct req *, char *);
 static  void             http_print(const char *);  static  void             http_print(const char *);
 static  void             http_putchar(char);  static  void             http_putchar(char);
 static  void             http_printquery(const struct req *);  static  void             http_printquery(const struct req *);
 static  void             pathgen(DIR *, struct req *);  static  void             pathgen(struct req *);
 static  void             pg_index(const struct req *, char *);  static  void             pg_index(const struct req *, char *);
 static  void             pg_search(const struct req *, char *);  static  void             pg_search(const struct req *, char *);
 static  void             pg_show(const struct req *, char *);  static  void             pg_show(const struct req *, char *);
Line 829  int
Line 828  int
 main(void)  main(void)
 {  {
         int              i;          int              i;
         DIR             *cwd;  
         struct req       req;          struct req       req;
         char            *p, *path, *subpath;          char            *p, *path, *subpath;
   
Line 857  main(void)
Line 855  main(void)
                 perror(cache);                  perror(cache);
                 resp_bad();                  resp_bad();
                 return(EXIT_FAILURE);                  return(EXIT_FAILURE);
         } else if (NULL == (cwd = opendir(cache))) {  
                 perror(cache);  
                 resp_bad();  
                 return(EXIT_FAILURE);  
         }          }
   
         memset(&req, 0, sizeof(struct req));          memset(&req, 0, sizeof(struct req));
           pathgen(&req);
   
         pathgen(cwd, &req);  
         closedir(cwd);  
   
         /* Next parse out the query string. */          /* Next parse out the query string. */
   
         if (NULL != (p = getenv("QUERY_STRING")))          if (NULL != (p = getenv("QUERY_STRING")))
Line 938  cmp(const void *p1, const void *p2)
Line 930  cmp(const void *p1, const void *p2)
  * Scan for indexable paths.   * Scan for indexable paths.
  */   */
 static void  static void
 pathgen(DIR *dir, struct req *req)  pathgen(struct req *req)
 {  {
         struct dirent   *d;          FILE    *fp;
 #if defined(__sun)          char    *dp;
         struct stat      sb;          size_t   dpsz;
 #endif  
   
         while (NULL != (d = readdir(dir))) {          if (NULL == (fp = fopen("manpath.conf", "r")))
 #if defined(__sun)                  return;
                 stat(d->d_name, &sb);  
                 if (!(S_IFDIR & sb.st_mode)          while (NULL != (dp = fgetln(fp, &dpsz))) {
 #else                  req->p = mandoc_realloc(req->p,
                 if (DT_DIR != d->d_type                      (req->psz + 1) * sizeof(char *));
 #endif                  req->p[req->psz++] = mandoc_strndup(dp, dpsz);
                     || '.' != d->d_name[0]) {  
                         req->p = mandoc_realloc(req->p,  
                             (req->psz + 1) * sizeof(char *));  
                         req->p[req->psz++] = mandoc_strdup(d->d_name);  
                 }  
         }          }
 }  }

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

CVSweb