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

Diff for /mandoc/cgi.c between version 1.40 and 1.41

version 1.40, 2012/03/23 09:03:07 version 1.41, 2012/03/24 00:31:55
Line 495  resp_baddb(void)
Line 495  resp_baddb(void)
 static void  static void
 resp_search(struct res *r, size_t sz, void *arg)  resp_search(struct res *r, size_t sz, void *arg)
 {  {
         int               i;          size_t           i, matched;
         const struct req *req;          const struct req *req;
   
         req = (const struct req *)arg;          req = (const struct req *)arg;
   
         if (sz > 0)          if (sz > 0)
                 assert(req->q.manroot >= 0);                  assert(req->q.manroot >= 0);
   
           for (matched = i = 0; i < sz; i++)
                   if (r[i].matched)
                           matched++;
   
         if (1 == sz) {          if (1 == matched) {
                   for (i = 0; i < sz; i++)
                           if (r[i].matched)
                                   break;
                 /*                  /*
                  * If we have just one result, then jump there now                   * If we have just one result, then jump there now
                  * without any delay.                   * without any delay.
Line 511  resp_search(struct res *r, size_t sz, void *arg)
Line 518  resp_search(struct res *r, size_t sz, void *arg)
                 puts("Status: 303 See Other");                  puts("Status: 303 See Other");
                 printf("Location: http://%s%s/show/%d/%u/%u.html?",                  printf("Location: http://%s%s/show/%d/%u/%u.html?",
                                 host, progname, req->q.manroot,                                  host, progname, req->q.manroot,
                                 r[0].volume, r[0].rec);                                  r[i].volume, r[i].rec);
                 http_printquery(req);                  http_printquery(req);
                 puts("\n"                  puts("\n"
                      "Content-Type: text/html; charset=utf-8\n");                       "Content-Type: text/html; charset=utf-8\n");
                 return;                  return;
         }          }
   
         qsort(r, sz, sizeof(struct res), cmp);  
   
         resp_begin_html(200, NULL);          resp_begin_html(200, NULL);
         resp_searchform(req);          resp_searchform(req);
   
         puts("<DIV CLASS=\"results\">");          puts("<DIV CLASS=\"results\">");
   
         if (0 == sz) {          if (0 == matched) {
                 puts("<P>\n"                  puts("<P>\n"
                      "No results found.\n"                       "No results found.\n"
                      "</P>\n"                       "</P>\n"
Line 534  resp_search(struct res *r, size_t sz, void *arg)
Line 539  resp_search(struct res *r, size_t sz, void *arg)
                 return;                  return;
         }          }
   
           qsort(r, sz, sizeof(struct res), cmp);
   
         puts("<TABLE>");          puts("<TABLE>");
   
         for (i = 0; i < (int)sz; i++) {          for (i = 0; i < sz; i++) {
                   if ( ! r[i].matched)
                           continue;
                 printf("<TR>\n"                  printf("<TR>\n"
                        "<TD CLASS=\"title\">\n"                         "<TD CLASS=\"title\">\n"
                        "<A HREF=\"%s/show/%d/%u/%u.html?",                         "<A HREF=\"%s/show/%d/%u/%u.html?",
Line 870  out:
Line 879  out:
 static void  static void
 pg_search(const struct req *req, char *path)  pg_search(const struct req *req, char *path)
 {  {
         size_t            tt;          size_t            tt, ressz;
         struct manpaths   ps;          struct manpaths   ps;
         int               i, sz, rc;          int               i, sz, rc;
         const char       *ep, *start;          const char       *ep, *start;
           struct res      *res;
         char            **cp;          char            **cp;
         struct opts       opt;          struct opts       opt;
         struct expr      *expr;          struct expr      *expr;
Line 891  pg_search(const struct req *req, char *path)
Line 901  pg_search(const struct req *req, char *path)
         rc       = -1;          rc       = -1;
         sz       = 0;          sz       = 0;
         cp       = NULL;          cp       = NULL;
           ressz    = 0;
           res      = NULL;
   
         /*          /*
          * Begin by chdir()ing into the root of the manpath.           * Begin by chdir()ing into the root of the manpath.
Line 938  pg_search(const struct req *req, char *path)
Line 950  pg_search(const struct req *req, char *path)
   
         if (NULL != expr)          if (NULL != expr)
                 rc = apropos_search                  rc = apropos_search
                         (ps.sz, ps.paths, &opt,                          (ps.sz, ps.paths, &opt, expr, tt,
                          expr, tt, (void *)req, resp_search);                           (void *)req, &ressz, &res, resp_search);
   
         /* ...unless errors occured. */          /* ...unless errors occured. */
   
         if (0 == rc)          if (0 == rc)
                 resp_baddb();                  resp_baddb();
         else if (-1 == rc)          else if (-1 == rc)
                 resp_search(NULL, 0, (void *)req);                  resp_search(NULL, 0, NULL);
   
         for (i = 0; i < sz; i++)          for (i = 0; i < sz; i++)
                 free(cp[i]);                  free(cp[i]);
   
         free(cp);          free(cp);
           resfree(res, ressz);
         exprfree(expr);          exprfree(expr);
         manpath_free(&ps);          manpath_free(&ps);
 }  }

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41

CVSweb