GainSpan Wi-Fi library see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Dependents: GSwifi_httpd GSwifi_websocket GSwifi_tcpclient GSwifi_tcpserver ... more
Fork of GSwifi by
GainSpan Wi-Fi library
The GS1011 is an ultra low power 802.11b wireless module from GainSpan.
see: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
ゲインスパン Wi-Fi モジュール ライブラリ
ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011 シリーズ用のライブラリです。
解説: http://mbed.org/users/gsfan/notebook/gainspan_wifi/
Diff: GSwifi_httpd.cpp
- Revision:
- 25:f6e5622d2930
- Parent:
- 24:5c350ae2e703
- Child:
- 26:b347ee3a1087
--- a/GSwifi_httpd.cpp Wed Jan 23 07:41:23 2013 +0000 +++ b/GSwifi_httpd.cpp Mon Feb 11 06:01:46 2013 +0000 @@ -1,3 +1,25 @@ +/* Copyright (C) 2013 gsfan, MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +/** @file + * @brief Gainspan wi-fi module library for mbed + * GS1011MIC, GS1011MIP, GainSpan WiFi Breakout, etc. + */ + #include "dbg.h" #include "mbed.h" #include "GSwifi.h" @@ -6,19 +28,20 @@ #ifdef GS_USE_HTTPD -#define MIMETABLE_NUM 8 +#define MIMETABLE_NUM 9 struct { - char ext[6]; + char ext[5]; char type[24]; } mimetable[MIMETABLE_NUM] = { - {".txt", "text/plain"}, - {".html", "text/html"}, - {".htm", "text/html"}, - {".css", "text/css"}, - {".js", "application/javascript"}, - {".jpg", "image/jpeg"}, - {".png", "image/png"}, - {".gif", "image/gif"}, + {"txt", "text/plain"}, // default + {"html", "text/html"}, + {"htm", "text/html"}, + {"css", "text/css"}, + {"js", "application/javascript"}, + {"jpg", "image/jpeg"}, + {"png", "image/png"}, + {"gif", "image/gif"}, + {"ico", "image/x-icon"}, }; int GSwifi::httpd (int port) { @@ -76,7 +99,7 @@ } // get 1 line for (j = 0; j < len; j ++) { - _gs_sock[cid].data->get(&c); + _gs_sock[cid].data->dequeue(&c); if (c == '\r') continue; if (c == '\n' && _httpd[cid].mode != GSHTTPDMODE_BODY) break; @@ -314,7 +337,8 @@ DBG("<%s>\r\n", file); for (i = 0; i < MIMETABLE_NUM; i ++) { j = strlen(mimetable[i].ext); - if (strnicmp(&file[strlen(file) - j], mimetable[i].ext, j) == NULL) { + if (file[strlen(file) - j - 1] == '.' && + strnicmp(&file[strlen(file) - j], mimetable[i].ext, j) == NULL) { return mimetable[i].type; } } @@ -322,7 +346,7 @@ } int GSwifi::strnicmp (char *p1, char *p2, int n) { - int i, r; + int i, r = -1; char c1, c2; for (i = 0; i < n; i ++) { @@ -405,7 +429,7 @@ flg = 0; // get 1 line for (j = 0; j < len; j ++) { - _gs_sock[cid].data->get((char*)&c); + _gs_sock[cid].data->dequeue((char*)&c); // DBG("_%c", c); switch (_httpd[cid].mode) {