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:
- 29:1c4419512941
- Parent:
- 26:b347ee3a1087
- Child:
- 31:0abdc584823d
--- a/GSwifi_httpd.cpp Fri Feb 22 03:07:43 2013 +0000 +++ b/GSwifi_httpd.cpp Tue Feb 26 02:48:31 2013 +0000 @@ -30,8 +30,8 @@ #define MIMETABLE_NUM 9 struct { - char ext[5]; - char type[24]; + const char ext[5]; + const char type[24]; } mimetable[MIMETABLE_NUM] = { {"txt", "text/plain"}, // default {"html", "text/html"}, @@ -190,12 +190,17 @@ #ifdef GS_USE_WEBSOCKET if (flg && _httpd[cid].mode == GSHTTPDMODE_WEBSOCKET) { // websocket - _httpd[cid].host = _gs_sock[cid].host; - j = strlen(_handler[i].uri); - _httpd[cid].file = &_httpd[cid].uri[j]; - _httpd[cid].query = NULL; + i = get_handler(_httpd[cid].uri); + if (i >= 0 && _handler[i].onHttpCgi) { + _httpd[cid].host = _gs_sock[cid].host; + _httpd[cid].file = NULL; + _httpd[cid].query = NULL; - send_websocket_accept(cid); + send_websocket_accept(cid); + } else { + // not found + send_httpd_error(cid, 403); + } break; // exit while } else @@ -331,11 +336,11 @@ for (i = 0; i < MIMETABLE_NUM; i ++) { j = strlen(mimetable[i].ext); if (file[strlen(file) - j - 1] == '.' && - strnicmp(&file[strlen(file) - j], mimetable[i].ext, j) == NULL) { - return mimetable[i].type; + strnicmp(&file[strlen(file) - j], (char*)mimetable[i].ext, j) == NULL) { + return (char*)mimetable[i].type; } } - return mimetable[0].type; + return (char*)mimetable[0].type; } int GSwifi::strnicmp (char *p1, char *p2, int n) { @@ -550,26 +555,6 @@ } // while } -int GSwifi::send_websocket (int cid, const char *buf, int len) { - int r; - char tmp[10]; - - tmp[0] = 0x81; // single, text frame - if (len < 126) { - tmp[1] = len; - r = send(cid, tmp, 2); - } else { - tmp[1] = 126; - tmp[2] = (len >> 8) & 0xff; - tmp[3] = len & 0xff; - r = send(cid, tmp, 4); - } - if (r == 0) { - r = send(cid, buf, len); - } - return r; -} - void GSwifi::send_websocket_accept (int cid) { char buf[100], buf2[20];