Add other string search method for cgi table.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 3 Oct 2011 12:33:28 +0000 (12:33 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 3 Oct 2011 12:33:28 +0000 (12:33 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5131 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/net/http.c
bertos/net/http.h

index e3fc8085790e661dc556e571b068d76142426582..8941105232539e0afcebfab0cdef99d9b0f7aaab 100644 (file)
@@ -104,6 +104,7 @@ void http_getPageName(const char *revc_buf, size_t recv_len, char *page_name, si
                        *revc_buf++ == 'E' && *revc_buf++ == 'T')
                        {
                                str_ok = true;
+                               /* skip the space and "/" */
                                revc_buf += 2;
                        }
        }
@@ -149,9 +150,15 @@ static http_handler_t cgi_search(const char *name,  HttpCGI *table)
                        if (!strcmp(table[i].name, ext))
                                break;
                }
-               else /* (table[i].type == CGI_MATCH_NAME) */
+               else if (table[i].type == CGI_MATCH_NAME)
                {
                        LOG_INFO("Match all name %s\n", name);
+                       if (strstr(name, table[i].name) != NULL)
+                               break;
+               }
+               else /* (table[i].type == CGI_MATCH_WORD) */
+               {
+                       LOG_INFO("Match all word %s\n", name);
                        if (!strcmp(table[i].name, name))
                                break;
                }
index 665e97aa711b8e4aa14b0f4b163aa61a8e1e37a5..2b49c7f0b7dd7abbb084711842187df394f943ae 100644 (file)
@@ -56,8 +56,9 @@ typedef struct HttpCGI
 
 
 #define CGI_MATCH_NONE   0
-#define CGI_MATCH_NAME   1  ///< Select item in table only if string match
+#define CGI_MATCH_WORD   1  ///< Select item in table only if string match
 #define CGI_MATCH_EXT    2  ///< Select item in table if the extention match
+#define CGI_MATCH_NAME   3  ///< Select item in table if the string is content
 
 void http_getPageName(const char *revc_buf, size_t recv_len, char *page_name, size_t len);