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

Diff for /mandoc/cgi.c between version 1.64 and 1.65

version 1.64, 2014/07/12 01:55:30 version 1.65, 2014/07/12 16:14:35
Line 49  struct query {
Line 49  struct query {
         const char      *arch; /* architecture */          const char      *arch; /* architecture */
         const char      *sec; /* manual section */          const char      *sec; /* manual section */
         const char      *expr; /* unparsed expression string */          const char      *expr; /* unparsed expression string */
         int              legacy; /* whether legacy mode */          int              equal; /* match whole names, not substrings */
 };  };
   
 struct  req {  struct  req {
Line 142  http_printquery(const struct req *req)
Line 142  http_printquery(const struct req *req)
                 http_print(req->q.arch);                  http_print(req->q.arch);
         }          }
         if (NULL != req->q.expr) {          if (NULL != req->q.expr) {
                 printf("&expr=");                  printf("&query=");
                 http_print(req->q.expr ? req->q.expr : "");                  http_print(req->q.expr);
         }          }
           if (0 == req->q.equal)
                   printf("&apropos=1");
 }  }
   
 static void  static void
Line 164  html_printquery(const struct req *req)
Line 166  html_printquery(const struct req *req)
                 html_print(req->q.arch);                  html_print(req->q.arch);
         }          }
         if (NULL != req->q.expr) {          if (NULL != req->q.expr) {
                 printf("&expr=");                  printf("&query=");
                 html_print(req->q.expr);                  html_print(req->q.expr);
         }          }
           if (0 == req->q.equal)
                   printf("&apropos=1");
 }  }
   
 static void  static void
Line 202  static void
Line 206  static void
 http_parse(struct req *req, char *p)  http_parse(struct req *req, char *p)
 {  {
         char            *key, *val;          char            *key, *val;
         int              legacy;  
   
         memset(&req->q, 0, sizeof(struct query));          memset(&req->q, 0, sizeof(struct query));
         req->q.manpath = req->p[0];          req->q.manpath = req->p[0];
           req->q.equal = 1;
   
         legacy = -1;  
         while ('\0' != *p) {          while ('\0' != *p) {
                 key = p;                  key = p;
                 val = NULL;                  val = NULL;
Line 228  http_parse(struct req *req, char *p)
Line 231  http_parse(struct req *req, char *p)
                 if (NULL != val && ! http_decode(val))                  if (NULL != val && ! http_decode(val))
                         break;                          break;
   
                 if (0 == strcmp(key, "expr"))                  if (0 == strcmp(key, "query"))
                         req->q.expr = val;                          req->q.expr = val;
                 else if (0 == strcmp(key, "query"))  
                         req->q.expr = val;  
                 else if (0 == strcmp(key, "sec"))  
                         req->q.sec = val;  
                 else if (0 == strcmp(key, "sektion"))  
                         req->q.sec = val;  
                 else if (0 == strcmp(key, "arch"))  
                         req->q.arch = val;  
                 else if (0 == strcmp(key, "manpath"))                  else if (0 == strcmp(key, "manpath"))
                         req->q.manpath = val;                          req->q.manpath = val;
                 else if (0 == strcmp(key, "apropos"))                  else if (0 == strcmp(key, "apropos"))
                         legacy = 0 == strcmp(val, "0");                          req->q.equal = !strcmp(val, "0");
                   else if (0 == strcmp(key, "sec") ||
                            0 == strcmp(key, "sektion")) {
                           if (strcmp(val, "0"))
                                   req->q.sec = val;
                   } else if (0 == strcmp(key, "arch")) {
                           if (strcmp(val, "default"))
                                   req->q.arch = val;
                   }
         }          }
   
         /* Test for old man.cgi compatibility mode. */  
   
         req->q.legacy = legacy > 0;  
   
         /*  
          * Section "0" means no section when in legacy mode.  
          * For some man.cgi scripts, "default" arch is none.  
          */  
   
         if (req->q.legacy && NULL != req->q.sec)  
                 if (0 == strcmp(req->q.sec, "0"))  
                         req->q.sec = NULL;  
         if (req->q.legacy && NULL != req->q.arch)  
                 if (0 == strcmp(req->q.arch, "default"))  
                         req->q.arch = NULL;  
 }  }
   
 static void  static void
Line 368  resp_searchform(const struct req *req)
Line 355  resp_searchform(const struct req *req)
                "<FORM ACTION=\"%s/search\" METHOD=\"get\">\n"                 "<FORM ACTION=\"%s/search\" METHOD=\"get\">\n"
                "<FIELDSET>\n"                 "<FIELDSET>\n"
                "<LEGEND>Search Parameters</LEGEND>\n"                 "<LEGEND>Search Parameters</LEGEND>\n"
                "<INPUT TYPE=\"submit\" "                 "<INPUT TYPE=\"submit\" VALUE=\"Search\"> "
                " VALUE=\"Search\"> for manuals matching \n"                 "for manuals \n",
                "<INPUT TYPE=\"text\" NAME=\"expr\" VALUE=\"",  
                scriptname);                 scriptname);
           printf("<SELECT NAME=\"apropos\">\n"
                  "<OPTION VALUE=\"0\"");
           if (req->q.equal)
                   printf(" SELECTED=\"selected\"");
           printf(">named</OPTION>\n"
                  "<OPTION VALUE=\"1\"");
           if (0 == req->q.equal)
                   printf(" SELECTED=\"selected\"");
           printf(">matching</OPTION>\n"
                  "</SELECT>\n"
                  "<INPUT TYPE=\"text\" NAME=\"query\" VALUE=\"");
         html_print(req->q.expr ? req->q.expr : "");          html_print(req->q.expr ? req->q.expr : "");
         printf("\">, section "          printf("\">, section "
                "<INPUT TYPE=\"text\""                 "<INPUT TYPE=\"text\""
Line 784  pg_search(const struct req *req, char *path)
Line 781  pg_search(const struct req *req, char *path)
   
         search.arch = req->q.arch;          search.arch = req->q.arch;
         search.sec = req->q.sec;          search.sec = req->q.sec;
         search.deftype = TYPE_Nm | TYPE_Nd;          search.deftype = req->q.equal ? TYPE_Nm : (TYPE_Nm | TYPE_Nd);
         search.flags = 0;          search.flags = req->q.equal ? MANSEARCH_MAN : 0;
   
         paths.sz = 1;          paths.sz = 1;
         paths.paths = mandoc_malloc(sizeof(char *));          paths.paths = mandoc_malloc(sizeof(char *));

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65

CVSweb