Compare commits

..
1645 Commits
Author SHA1 Message Date
Deomid Ryabkov 81d977c720 Introduce mg_time() and use it internally
PUBLISHED_FROM=024a2d7849a800381d58460877eacccfc93b1cdd
2016-01-11 12:24:40 +03:00
Alexander Alashkin f477898c7c Mongoose 6.1 -> 6.2
PUBLISHED_FROM=24146cf7f4cf86cfd76260fb906d50889b9d6f7e
2016-01-11 12:24:40 +03:00
Marko Mikulicic 566193a1eb Implement freezing V7 object graph
PUBLISHED_FROM=1670ce871ed2c9391edb10ff413d3d454997d1fe
2016-01-11 12:24:40 +03:00
Deomid Ryabkov 5d6eeb5d1d Add a note about Content-Type for form submissions
PUBLISHED_FROM=6079258be24fa0255f5a58e4d364be224435394b
2016-01-11 12:24:39 +03:00
Dmitry Frank d9b9d71b2d v7_apply() and friends take res as last argument
PUBLISHED_FROM=4b064f5e4554c5a016481bf8104c0ba9dd244083
2016-01-11 12:24:38 +03:00
Dmitry Frank 643ee1df14 cfunctions API refactored to return enum v7_err
PUBLISHED_FROM=f96a4ab2016c0125c1e94b3c5c9ada2c365bd39d
2016-01-11 12:24:36 +03:00
Deomid Ryabkov 6c4d37ee68 Free previous ssl context in mg_set_ssl
PUBLISHED_FROM=9f595222bce1fe8d0917649e36ce3be40eee1775
2015-12-23 17:02:52 +01:00
Sergey Lyubka 97b79cd04a Add MacOS to mongoose README
PUBLISHED_FROM=679b640e3de8b0fbd65b38263093dd6049db4cd3
2015-12-23 17:02:52 +01:00
Sergey Lyubka 56c6229dd6 Update Mongoose readme
PUBLISHED_FROM=ac117f203ef11b9c3877a6dd1919e8409d04cdb1
2015-12-22 07:42:12 +00:00
Dmitry Frank 0fe2dd9b48 Added param names to mongoose headers
PUBLISHED_FROM=07bd8163c4e1df49ab3dc7a1640efa2adff34e33
2015-12-22 07:42:11 +00:00
Sergey Lyubka 910aee7f7b Re-enable mongosoe FS support on ESP
PUBLISHED_FROM=cfa1c79bb5429feddf38c68c25195b97deef9a62
2015-12-22 07:33:06 +00:00
Sergey Lyubka 97063937ff Add vanilla forum to forum.cesanta.com
PUBLISHED_FROM=bff863108d0fb80a6139ac34be04fb999e18e62e
2015-12-22 07:33:06 +00:00
Sergey Lyubka 7e68b097d1 Close https://github.com/cesanta/mongoose/pull/603
PUBLISHED_FROM=ab934b21ed67878f47ccd569d88030e53e914bf7
2015-12-21 08:37:20 +00:00
Marko Mikulicic 4d41dff4fd Fix includes
PUBLISHED_FROM=58d764bb224968d5368b21a8eb572602055cb26b
2015-12-21 08:37:19 +00:00
Deomid Ryabkov 05082cec88 Use sub-second time for timers in MG
PUBLISHED_FROM=2b5bd1589465a5f43bc888c689842332cf7cdf98
2015-12-20 17:49:13 +00:00
Marko Mikulicic f05733da69 Fix COAP example, reduce number of ctx switches
PUBLISHED_FROM=7010fff404826c3dfc783d2cbdcbd0936a8a2b85
2015-12-15 11:36:34 +01:00
Marko Mikulicic 3c53909e82 Foolproof Smartjs publishing
PUBLISHED_FROM=8ade849890746baa95fd8a5d92baf3dda656a719
2015-12-15 11:28:39 +01:00
Deomid Ryabkov 1e53ec47a9 Peeple TLS support for updates
PUBLISHED_FROM=1abdacaece6dc63b6148c605c4c2cc41c3cc4ac6
2015-12-15 11:28:38 +01:00
Sergey Lyubka 17802735d7 Spiffy config for cc3200
PUBLISHED_FROM=34b3678cb2510adfd5f26183ae7c16aadb97e6c9
2015-12-14 00:12:12 +01:00
Marko Mikulicic d2eb67a1ae Sanitize mongoose headers
PUBLISHED_FROM=d3790d175b8d714865c7eb5f12e82d31844a863f
2015-12-14 00:12:12 +01:00
Marko Mikulicic 3f254dd3fc Simplify include paths
PUBLISHED_FROM=4e38db207dc2634e410339c81c5a2a87e8b188b0
2015-12-14 00:12:12 +01:00
Deomid Ryabkov e139bde6ae A couple SSL-related fixes for Mongoose
PUBLISHED_FROM=03297850f7a620588de851ef86be25e17a04ad28
2015-12-11 13:02:13 +00:00
Sergey Lyubka 5f62951143 Runtime DAV auth disable. Implement MOVE
PUBLISHED_FROM=aec49928891972ecd6af9999fe3e1cb5ef00f24c
2015-12-11 13:02:13 +00:00
Sergey Lyubka 2207e87c8f Fix DAV for non-existent files. Improve logging
PUBLISHED_FROM=39a2810ad9bebcf1676b982f7523aa9c2339cc4f
2015-12-11 13:02:12 +00:00
Sergey Lyubka 5bd59c7b70 Shut up spiffs. Proper DAV report
PUBLISHED_FROM=125379f6c624b4e938b5d543cb8ed5fe906de98f
2015-12-11 13:02:12 +00:00
Alexander Alashkin 02f6867a2f Implement %lld in c_vsnprintf. Closes cesanta/dev#2120
PUBLISHED_FROM=1f24878425356f625b4f5b2b0fe40ab5f17501ab
2015-12-11 13:02:11 +00:00
Deomid Ryabkov b93fa3144a First cut of TLS support for LWIP event manager
PUBLISHED_FROM=98cf23ea090ffb4e83edd4d600bee57dfd7d94d4
2015-12-11 13:02:11 +00:00
Alexander Alashkin a68e0d9a3f Add WebDAV move stub
PUBLISHED_FROM=b1f712862b81dfe8da6547338f77ff3bfefa5051
2015-12-11 13:02:10 +00:00
Alexander Alashkin cfe80ba9b7 Add WebDAV support to sjs/esp8266
PUBLISHED_FROM=a68a2f205cb2f10809183d5160709981585538b7
2015-12-11 13:02:10 +00:00
Deomid Ryabkov 35abfd44dd Fix windows build
PUBLISHED_FROM=3b3788da8c2dcc57897044701c5252ea46db0249
2015-12-08 13:38:05 +00:00
Sergey Lyubka e98b5a691e Implement Http_request.setTimeout()
PUBLISHED_FROM=7a72e485aad2be859b9452dc1687a922778959d1
2015-12-08 13:38:05 +00:00
Sergey Lyubka ed24afd172 Connect timeouts for resolving connections
PUBLISHED_FROM=068b6f75550b10913d7f13106f9a7f7dce5babec
2015-12-08 12:35:29 +00:00
Deomid Ryabkov 714556de65 Added debug line to mg_mgr_handle_ctl_sock
PUBLISHED_FROM=a4c1d105cb4f18d982bd28190691b6ea65ee37fc
2015-12-08 12:35:29 +00:00
Deomid Ryabkov 547ec85b58 Properly disable socketpair-related stuff
PUBLISHED_FROM=f3a236470281af80848c8f78163980083190c081
2015-12-08 12:35:29 +00:00
Marko Mikulicic 845d751e87 Fix C String API confusion
PUBLISHED_FROM=af34acd81d877bfbd8441c14451d8c81f18c207d
2015-12-08 12:35:29 +00:00
Alexander Alashkin 518a7f8a71 Fix MG DAV
PUBLISHED_FROM=132db6ed9c9e1eb9ec19b4f9299448b901b92231
2015-12-08 12:35:29 +00:00
Sergey Lyubka 31323b01bc Introduce MG_EV_TIMER event
PUBLISHED_FROM=2e90ee87eda8bc742e427671bb9df1ce0cd8bc25
2015-12-08 12:35:28 +00:00
Deomid Ryabkov 3a138ecc83 Move more of SSL-specific code into net_if
PUBLISHED_FROM=47dc4712c0ea2012c0774ad260f0451371cfe8b7
2015-12-08 12:35:28 +00:00
Dmitry Frank 7294674a8b Remove custom strnlen for VC 16+
PUBLISHED_FROM=9c28b64267408929f5c565b87978816f3a93f06b
2015-12-08 12:35:27 +00:00
Sergey Lyubka 423b978395 Report read-only vars to UI
PUBLISHED_FROM=2ca4b52e777a54d9bb05a177e57a8b73bb962fdb
2015-12-08 12:35:27 +00:00
Sergey Lyubka ecf20ec7b8 Add error_log_file, use extended log format
PUBLISHED_FROM=d189b44857723871159826944bde9b87089bb0bd
2015-12-08 12:35:27 +00:00
Sergey Lyubka c948a509fb Export mg_url_decode() to public
PUBLISHED_FROM=442534f52992be612a98a549e5ab2191081a9d52
2015-12-03 22:05:52 +00:00
Sergey Lyubka f5ad19d76b Fix g++ build for mongoose example
PUBLISHED_FROM=c581f33e26819d05c9b8484c9dc10c2a3615a34a
2015-12-02 17:04:44 +00:00
Deomid Ryabkov d665d9e90e Always Be Closing
PUBLISHED_FROM=29ca7cdd9024790bd75892f9f67b3f83a6bd00d1
2015-12-01 18:03:19 +00:00
Sergey Lyubka a5e10450dd Mongoose 6.0 -> 6.1
PUBLISHED_FROM=22408f9340bbbbf186bd551dd30564efe0c253e3
2015-11-30 12:27:59 +00:00
Sergey Lyubka e9d79b130d Add documentation for the mongoose binary
PUBLISHED_FROM=71a01298c9bbff9a748ea33e0d148d549e5e6437
2015-11-30 12:27:59 +00:00
Deomid Ryabkov 7951dac9d5 Put getting local/remote address behinf net_if
PUBLISHED_FROM=f88056e79b632d9eee288dacf61c2f87ff3ceca5
2015-11-30 12:27:58 +00:00
Alexander Alashkin 6c77351c58 Verify settings before apply
PUBLISHED_FROM=ca7b6a9814b88b45d893d8e1386faded27305e9c
2015-11-30 12:27:58 +00:00
Sergey Lyubka 7c4cda622f Implement port based redirect
PUBLISHED_FROM=798a8bc38cb385027d3caae9b954002c1a10d39c
2015-11-30 12:27:57 +00:00
Deomid Ryabkov d8f8c1cb99 I fail at math
PUBLISHED_FROM=c45da0cf83e9573a9fa8234f4dee1b9e4e5b977a
2015-11-30 12:27:57 +00:00
Deomid Ryabkov d2b9ad570f Add a custom linker script for 4m flash
PUBLISHED_FROM=a92b86588923fb54075b1c3ed8ca8112164c36c5
2015-11-25 12:06:28 +00:00
Deomid Ryabkov 5b36f32996 Add ESP8266 RTOS example
PUBLISHED_FROM=892d01b09f5801d3d19e6db1ce22b7916d2f83d5
2015-11-24 00:42:27 +00:00
Deomid Ryabkov 3298030b8e Changes to make Mongoose compile on ESP RTOS SDK
PUBLISHED_FROM=863a47416ee5e30f20f6523374ebd510cc022d99
2015-11-24 00:42:27 +00:00
Sergey Lyubka 6cfc696439 Add helper function mg_send_head()
PUBLISHED_FROM=5c9d11d21d34fa72974a021f0342068d87159634
2015-11-24 00:42:26 +00:00
Sergey Lyubka a93b3a06dd Change binary download link
PUBLISHED_FROM=bc1a39dc8c11bab83c20da2c6e9477da0d17f993
2015-11-20 12:07:52 +00:00
Deomid Ryabkov 79e8d77ea0 Shave the debug yak
PUBLISHED_FROM=402d26b6a2797bfe9fb70e48cbde97f3960ef5d4
2015-11-20 12:07:51 +00:00
Sergey Lyubka d68fab9ee5 Enable threads on Win by default
PUBLISHED_FROM=cc4070d618f079ccd1e02e62bba87247e75c74aa
2015-11-20 12:07:51 +00:00
Sergey Lyubka bda470245e Support for multiple listeners
PUBLISHED_FROM=ad00f31ae8732be2d7fdc7f0968fd04edfd76bb6
2015-11-20 12:07:51 +00:00
Sergey Lyubka 0c95290f93 Add extra headers support (allows CORS)
PUBLISHED_FROM=2279e31315bba4d19e2ae568cba94ea5dea3ef6a
2015-11-18 07:44:23 +00:00
Deomid Ryabkov 8989739d32 Use mg_call to invoke user handler
PUBLISHED_FROM=cefd472946dfe77ec262c1980eab983a919b6220
2015-11-18 07:44:23 +00:00
Sergey Lyubka 1112981e6e Fix mg_if_not_modified() logic
PUBLISHED_FROM=3eb1455eacc66af83904f56397c0e24b1d4f13bf
2015-11-18 07:44:23 +00:00
Sergey Lyubka 0cf82744ce Unbreak macos tests
PUBLISHED_FROM=a9521579223cfbb68e2b7bcd221335d25dacbb87
2015-11-18 07:44:22 +00:00
Deomid Ryabkov 5cdf838325 Fix error handling in async resolver
PUBLISHED_FROM=1e8558ec08f8e72d70163d34e0920f80f74372d1
2015-11-18 07:44:22 +00:00
Sergey Lyubka 6418cad39f Disable HTTP keep-alive on embedded
PUBLISHED_FROM=63bb1ca0f307a4332006d6cd13a35f0be6359174
2015-11-18 07:44:22 +00:00
Sergey Lyubka 46529fd51e Remove unused MG_F_DONT_SEND
PUBLISHED_FROM=beaec58b808fb767b7e491d8b5d6b23a6d5e4e0c
2015-11-18 07:44:21 +00:00
Marko Mikulicic c09ba40a48 Cleanup make format target
PUBLISHED_FROM=5f856af633ca9a10161769caac130fc6452f137f
2015-11-18 07:44:20 +00:00
Sergey Lyubka 47d52896a1 s/uri/url, to conform to nodejs HTTP API
PUBLISHED_FROM=32ba0c859ad9df3cf7dc3af8e379e49543e77843
2015-11-18 07:44:19 +00:00
Deomid Ryabkov d60c99b01c Make MG debug go to stderr
PUBLISHED_FROM=11618b6b2a50c62dd612d241c6b13a9aab357909
2015-11-18 07:44:19 +00:00
Sergey Lyubka b8aeba06a2 Add unit test for mg_parse_date_string
PUBLISHED_FROM=aec7d5e6c6598fbc5141c40c9638cc96d288c8dc
2015-11-18 07:44:18 +00:00
Sergey Lyubka 8a0bc2d614 Mongoose binary - GUI version fix
PUBLISHED_FROM=94c2b4c5a40c3519df6caa7561c3935bdf505575
2015-11-18 07:44:18 +00:00
Deomid Ryabkov e34747d1ad Handle case of malloc failure in mbuf_resize
PUBLISHED_FROM=0cb98ac520b8aeb8bbeb2f23b8c65c62ab256021
2015-10-30 18:38:43 +01:00
Deomid Ryabkov 1a6bc7c514 Fix mbuf_resize(0)
PUBLISHED_FROM=7cab7543db990f7f67b53edca4f65ba45b219711
2015-10-30 18:38:42 +01:00
Deomid Ryabkov ffa0ddfdbf Make mg_call usable in protocol handlers
PUBLISHED_FROM=63ad74b31750a851db090d2f2995ecf5f275538b
2015-10-30 18:38:42 +01:00
Alexander Alashkin ca55bff1cf Fix mg compilation
PUBLISHED_FROM=ce7fdfebd3ebbf88688514be501b33ad1241743c
2015-10-30 18:38:42 +01:00
Deomid Ryabkov cfee5c4fdb Mongoose TCP listener for ESP LWIP
PUBLISHED_FROM=e88b17d21ee78a4c2c1c4832db322e19b314206d
2015-10-30 18:38:42 +01:00
Marko Mikulicic e46185068b Avoid inlining of esp gcc bug workaround
PUBLISHED_FROM=f02283b42d842246c75df848061a80b754a97013
2015-10-30 18:38:42 +01:00
Marko Mikulicic 6ef2fea45e Workaround lx106 gcc bug stack frame size rounding
PUBLISHED_FROM=66906d0e5f6d97b135bd157f5f82dc13bef2fb1a
2015-10-30 18:38:41 +01:00
Deomid Ryabkov e244dd84a9 Mongoose and LWIP fixes
PUBLISHED_FROM=c63992029098108ae62234176d4334207b43dd7b
2015-10-30 18:38:41 +01:00
Deomid Ryabkov 5034937a15 Set more reasonable WS buffer size
PUBLISHED_FROM=ecfc284747f1b3eef5c40dd74b4af19f4618edcc
2015-10-30 18:38:41 +01:00
Deomid Ryabkov 060045be65 Un-static a bunch of structs to save ram when idle
PUBLISHED_FROM=1a994be80dd46ffd410f88db28816c85b2c2bf79
2015-10-30 18:38:41 +01:00
Deomid Ryabkov 9adfe8d484 espconn is out, Mongoose + LWIP is in
PUBLISHED_FROM=c67ea324058d70070f89420c40e57b9df87964b1
2015-10-30 18:38:41 +01:00
Deomid Ryabkov 799cc369e0 Reduce stack usage when parsing HTTP URL
PUBLISHED_FROM=682f59e58d8335352cc09987a91e85cc264cf0f8
2015-10-30 18:38:41 +01:00
Deomid Ryabkov b97d3fea4b strnlen should return size_t
PUBLISHED_FROM=545c7d80380c48332803ef00981763b130a1c1c6
2015-10-30 18:38:40 +01:00
Deomid Ryabkov 2a4ca9d5c3 Introduce a network interface API, refactor UDP
PUBLISHED_FROM=6e961e2760b2b64e211978ede5df8ca353ea5512
2015-10-30 18:38:40 +01:00
Deomid Ryabkov 747e40e74e Fix size_t printing on CC3200
PUBLISHED_FROM=65b068a7620e7117c0dffc762d710e08dfbad037
2015-10-30 18:38:40 +01:00
Marko Mikulicic cf279e7885 Address ignored return values of read and write
PUBLISHED_FROM=d76b6b9d91d7af0e916cd81e1213c463757bf924
2015-10-30 18:38:39 +01:00
Marko Mikulicic cbf968735a Fix MG_SEND_FUNC/MG_RECV_FUNC rename fail
PUBLISHED_FROM=da28a75111abb5fb49b122133a66ae9bdf63f474
2015-10-30 18:38:39 +01:00
Sergey Lyubka 57b35e6007 Add JS HTTP server to smartjs
PUBLISHED_FROM=13210e55d9434917549dcbf9a39a5377181f8387
2015-10-21 17:34:55 +02:00
Deomid Ryabkov 1eaabdd8e5 s/dmg/dns/g
PUBLISHED_FROM=96dc8b0b4001f2206749a401c615f043fc5f6131
2015-10-21 15:17:11 +02:00
Sergey Lyubka dcd4e660a3 Serve current dir by default in mg_serve_http()
PUBLISHED_FROM=421b4256629b2bccd20ceb127ece02be57085b40
2015-10-21 15:17:11 +02:00
Deomid Ryabkov 96409e74e5 Fix ALL the leaks!
PUBLISHED_FROM=0adf7c6c903075d6705693829f8758f8ff67d579
2015-10-21 15:17:11 +02:00
Sergey Lyubka e28ee097a1 Move mongoose binary to dev repo
PUBLISHED_FROM=224a216abc4a7cca50d80f762dca602f54470105
2015-10-21 15:17:11 +02:00
Deomid Ryabkov 2b4e544867 Move "connect done" logic from mg_read_from_socket
PUBLISHED_FROM=318cc110d8b012cf75cb02dfc68a8215faa93fe7
2015-10-21 15:17:11 +02:00
Deomid Ryabkov ee042a3481 Fix SSI parsing
PUBLISHED_FROM=c918da948354def5815dfd6b832053f170212c6f
2015-10-16 12:57:02 +01:00
Alexander Alashkin 63075f6846 Add restful_client & restful_server VC projects
PUBLISHED_FROM=5ee78f5c907401c93a04f89d6b25b99515aa809a
2015-10-16 10:31:23 +01:00
Alexander Alashkin 7f2e42a06d Fix MSVC2015 build and add VC project
PUBLISHED_FROM=d071ecd0bdcc871cdd18a65c1ebb8b546ff61941
2015-10-16 10:31:23 +01:00
Sergey Lyubka 3fbfa33b9a Minor nitpicks for big_upload
PUBLISHED_FROM=55d4270916f32ce4645965fbd7a031d7f8e1907b
2015-10-13 10:38:36 +01:00
Maxim Ignatenko 179aa75047 Add big_upload example
PUBLISHED_FROM=58dfd3cfdbc5f908e5fa10171274f0d5dd256404
2015-10-13 10:38:36 +01:00
Maxim Ignatenko 4658194d08 Properly populate mg_connection.sa field
PUBLISHED_FROM=a305c720aee1b159847e10c962b6de7fe08bc787
2015-10-12 12:48:35 +01:00
Marko Mikulicic b35657814c Factor our LWIP enabling flag
PUBLISHED_FROM=d080ccb2d0daef1103ff7487b5c3f4b65ab97b99
2015-10-12 11:05:33 +01:00
Marko Mikulicic a2322c77c6 Fix mongoose build
PUBLISHED_FROM=ec4a774dfd690876201080ff55bdbec5bd865670
2015-10-12 11:05:33 +01:00
Marko Mikulicic b50c183c19 Simplify and abstract C func arg access
PUBLISHED_FROM=c174439a2d22794497dc35fd46ceb1f6c4e553a2
2015-10-12 11:05:32 +01:00
Maxim Ignatenko a941687db0 Fix mongoose build
PUBLISHED_FROM=aec35861339d336697649fd2020766439b3814ad
2015-10-12 11:05:32 +01:00
Marko Mikulicic c2eef52b65 Add CLA to mongoose README
PUBLISHED_FROM=9987c788e55bc949c06ebf355d51d38ef2d109d6
2015-10-12 11:05:32 +01:00
Claudiu 3e6cbbde04 Fix static function prototype
PUBLISHED_FROM=d90d06593ec4531f479053243c72601ee27a3141
2015-10-05 22:27:10 +02:00
Sergey Lyubka 6400536282 Rename v7_get_global_object() -> v7_get_global()
PUBLISHED_FROM=91a306d5dbc55d65505904b1a19cca5bbe9f58cc
2015-10-05 22:27:10 +02:00
Sergey Lyubka 776103068f Add examples for mongoose blog article
PUBLISHED_FROM=54f54211919bb2276e02b4d10306ffa5540a9313
2015-10-02 13:10:47 +01:00
Maxim Ignatenko 93beff3b65 Use select() by default everywhere
PUBLISHED_FROM=474789b0d7f5076434e5c15c079306243f3a8d81
2015-09-25 16:19:50 +01:00
Marko Mikulicic 22f8d86b05 Makes sure send file releases resources on close
PUBLISHED_FROM=451d2dd0b55b9fd7dea441a9279f54d0005c97b1
2015-09-25 16:19:50 +01:00
Marko Mikulicic 3a9a9c7ad0 Enable printf format warnings for mg_printf
PUBLISHED_FROM=61a52651a2542cb89b155623781a5fcbf64779f3
2015-09-25 16:19:50 +01:00
Alexander Alashkin 13238b1ad2 Restore win build
PUBLISHED_FROM=fe072db3dcc5f92f44d91a81596e33e404887951
2015-09-25 16:19:50 +01:00
Marko Mikulicic 56f661e9c6 Make mg send_http_file work for ESP8266 RTOS
PUBLISHED_FROM=10623cfe38e143f7e107a6494baa298c788586f0
2015-09-25 16:19:49 +01:00
Marko Mikulicic 5351f46efb Mongoose send on esp8266 RTOS_SDK
PUBLISHED_FROM=1e97853ebc1c39b01754cf76d875453842e9b36d
2015-09-25 16:19:49 +01:00
Sergey Lyubka 0cd3335b78 Update mongoose download link
PUBLISHED_FROM=70a6e34c6630e3ab95d200b173d22529101b61ea
2015-09-22 10:35:55 +01:00
Marko Mikulicic 0611627448 Serve a http file on quantex
PUBLISHED_FROM=856d2e0bdaddece638d215c252fabeb9ea2d7809
2015-09-22 10:32:02 +01:00
Sergey Lyubka f014918435 Add JS support to Mongoose
PUBLISHED_FROM=5f319c5c6d965432da063ce7ab495ae24e972755
2015-09-22 10:32:01 +01:00
Sergey Lyubka 51e016089e Nitpick README update
PUBLISHED_FROM=28b3a30ad82432e8e3ca194d7e204acf9a998e94
2015-09-22 10:32:01 +01:00
Sergey Lyubka 8a66ff5278 Mongoose rebrand changes
PUBLISHED_FROM=50497043e8d0c10487804263cdcb1cbb260d5a26
2015-09-21 15:19:35 +01:00
Sergey Lyubka e1dd3f06fe Rename Mongoose constants: NS_ -> MG_, NSF_ -> MG_F_
PUBLISHED_FROM=c9cc54df1883aa17606de2b1ffb30f0cd687d037
2015-09-21 15:19:34 +01:00
Deomid Ryabkov 32ab35f61f Rename hmac_sha1 -> cs_hmac_sha1
PUBLISHED_FROM=3d4fbd8192d04add406e304b113ce5ec0b1c1165
2015-09-21 15:19:34 +01:00
Marko Mikulicic 8ab96ec74b Implement binary and incremental clubby client
PUBLISHED_FROM=ba371b8a3d9dd8afcb771144beb8e5c344c7d6c7
2015-09-21 15:19:33 +01:00
Sergey Lyubka 0730590e35 Fix SSL codepath in restful_server example
PUBLISHED_FROM=4cd52839b8d2396f50f94f1ce36fa7b4501dc204
2015-09-21 15:19:33 +01:00
Marko Mikulicic f7e0b1331c Implement incremental UBJSON serializer
PUBLISHED_FROM=fe0936cbf8c16d5b5cfdf674e8e7181f6b2771cc
2015-09-21 15:19:33 +01:00
Marko Mikulicic 17aa2a7092 Implement streaming base64 encoder
PUBLISHED_FROM=af3c6c0e8f9806c1bdc570c06cc6eea9995d6e3d
2015-09-21 15:19:33 +01:00
Alexander Alashkin 7d38d05ca7 Use updated sockets
PUBLISHED_FROM=30231da54720c709ce98cd0ab208cf9b06814eab
2015-09-21 15:19:33 +01:00
TheTypoMaster 33bad047f0 Fix typo recieve
PUBLISHED_FROM=6e2f4fffb91ff18da94d97aba763acbdde496515
2015-09-09 10:21:21 +01:00
Marko Mikulicic 5234b73c29 Add simple core dumper for ESP
PUBLISHED_FROM=ec98516ce6aa1c841344adc7aae20b044b3d349b
2015-09-09 10:21:21 +01:00
Sergey Lyubka c566e2eba5 Mongoose README
PUBLISHED_FROM=f2409461d1ef4eef81b5481914bee5e596e906f8
2015-09-08 14:42:13 +02:00
Marko Mikulicic e565977481 Merge pull request #568 from cesanta/fossamerge
Merge dev branch code named Fossa as next stable Mongoose
2015-09-08 14:39:52 +02:00
Marko Mikulicic 8927c9d22b Merge dev branch code named Fossa as next stable Mongoose 2015-09-08 14:34:30 +02:00
Marko Mikulicic 28eb251ccd Merge pull request #567 from cesanta/move
Fossa merge
2015-09-08 13:28:38 +02:00
Sergey Lyubka b99dc95b1d Fossa merge.
PUBLISHED_FROM=12ccba10358075024a1195cd0b0c1ea132aae6a3
2015-09-08 12:26:25 +01:00
Sergey Lyubka 75aadb3e79 Fix links 2015-08-26 11:23:54 +01:00
Sergey Lyubka b6ecd5fb4c Update readme 2015-08-20 10:20:02 +01:00
Sergey Lyubka 1e7f55ed84 Update readme 2015-08-20 08:56:14 +01:00
Sergey Lyubka eeadc5ecff Updated readme 2015-08-18 12:21:33 +01:00
Sergey Lyubka 568ca42988 Updated readme 2015-08-18 11:26:43 +01:00
Sergey Lyubka 7b758bfc9d Updated readme 2015-08-18 10:47:23 +01:00
Sergey Lyubka 8ef454b75f Updated readme 2015-08-18 09:50:00 +01:00
Marko Mikulicic 0a2f2fda5c Merge pull request #563 from cesanta/sdp
Tweak event handler a bit for clarity
2015-08-13 15:42:45 +02:00
rojer 6b440918ec Tweak event handler a bit for clarity
Put cases in the order we expect them to occur
2015-08-13 14:38:41 +01:00
Marko Mikulicic a73fce945c Merge pull request #562 from cesanta/sdp
Swallow responses to internal pings
2015-08-12 19:45:04 +02:00
rojer d349bb3cc7 Swallow responses to internal pings 2015-08-12 18:35:18 +01:00
Marko Mikulicic 7c4119a287 Merge pull request #561 from cesanta/sdp
Mongoose example for server data push
2015-08-12 18:52:51 +02:00
rojer 8a71ad99e6 Mongoose example for server data push 2015-08-12 17:42:05 +01:00
Sergey Lyubka 41b405d7bf Remove examples/web_server 2015-07-13 11:14:19 +01:00
Sergey Lyubka 30b80dc5ee Update example 2015-07-13 11:11:26 +01:00
Sergey Lyubka 524aa2e586 Merge pull request #556 from nesteroff/vs2013
Fix VS2013 warnings
2015-07-13 11:03:13 +01:00
Yuri Nesterov 990a1b9ae0 Fix VS2013 warnings 2015-07-12 15:43:54 +03:00
Sergey Lyubka 4cb0c6864e Merge pull request #550 from cesanta/fixpolar
Fix ssl close with polarssl
2015-07-02 17:06:30 +01:00
Marko Mikulicic 5183693951 Fix ssl close with polarssl 2015-07-02 16:26:31 +02:00
Sergey Lyubka e47506f957 Fix unauthenticated body handling 2015-06-22 12:05:31 +01:00
Sergey Lyubka 824e4dc0e4 Fix file upload iteration 2015-06-19 19:01:21 +01:00
Sergey Lyubka d033497714 Merge pull request #541 from NickCis/connection_param_fix
Possible fix in order not to loose the reference of connection_param pointer
2015-06-10 15:32:28 +01:00
Nicolas Cisco d8028df29d Quick fix in order not to loose the reference of connection_param pointer 2015-06-10 01:49:37 -03:00
Sergey Lyubka 564683d25a Fix timeout for cookie auth example 2015-06-05 18:09:27 +01:00
Sergey Lyubka 30c0a3f201 Propagate select() and socketpair() errors to the user 2015-06-04 11:27:31 +01:00
Sergey Lyubka 08fe9ac518 Fix examples 2015-05-20 10:53:10 +01:00
Sergey Lyubka 14d6f71f82 Fix unit test 2015-05-20 10:50:32 +01:00
Sergey Lyubka 29454e2296 Merge pull request #524 from NickCis/array_variables
Implementing array varibles
2015-05-20 10:05:48 +01:00
NickCis d6cbf9f77d Fixing C coding style mistakes 2015-05-19 13:54:35 -03:00
Sergey Lyubka b9fead4d6e Merge pull request #525 from NickCis/mg_vprintf
Adding mg_vprintf and mg_vprintf_data.
2015-05-19 15:54:27 +01:00
Sergey Lyubka c6a04e1719 Fix #523 2015-05-18 11:50:56 +01:00
NickCis c839a61fea Adding mg_vprintf and mg_vprintf_data in order to use va_list like functions 2015-05-15 16:20:33 -03:00
NickCis c06abbc5f7 Implementing array varibles 2015-05-15 15:49:35 -03:00
Sergey Lyubka c8e88e1710 Sync fossa struct definitions 2015-05-15 17:20:54 +01:00
Sergey Lyubka bf7a115bf2 Fix url rewrites 2015-05-11 09:13:46 +01:00
Sergey Lyubka b8dfb69cf5 Merge pull request #514 from cesanta/fix_setsize
Fix default windows FD_SETSIZE, closes #506
2015-04-17 07:10:24 +01:00
Marko Mikulicic 1cd9715095 Fix default windows FD_SETSIZE, closes #506
https://support.microsoft.com/en-us/kb/111855 describes
that the user is expected to set the FD_SETSIZE macro
before including winsock2.h
2015-04-17 02:30:22 +02:00
Sergey Lyubka 5c7aeac148 Merge pull request #509 from cesanta/Fix_mjpg_streamer_example
Fix mjpg_streamer example
2015-04-13 23:37:27 +01:00
Alexander Alashkin 09a80628e6 Fix mjpg_streamer example 2015-04-13 16:02:52 +03:00
Sergey Lyubka 2ff2c369f7 Merge pull request #505 from eugoss/master
Inspect POST buffer in mg_get_var() only if first call of get_var() returns -1
2015-04-10 18:31:15 +01:00
Marko Mikulicic eef70aaf74 Merge pull request #507 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-04-09 13:04:18 +02:00
The Gitter Badger 89ac97caba Added Gitter badge 2015-04-09 10:58:41 +00:00
Eugene Ossintsev c00b236c8d Fix spelling in docs/ReleaseNotes.md and in comments in mongoose.c 2015-04-09 00:15:40 -04:00
Eugene Ossintsev eacd3f35e0 Inspect POST buffer in mg_get_var() only if first call of get_var() returns -1
In mg_get_var() the first call of get_var() inspects the variables of
the query string. If the requested variable is found but the destination
buffer is too small to hold the variable, return -2 right away. If it's
not found, make the second call of get_var() to inspect the POST buffer.
2015-04-05 23:40:50 -04:00
Marko Mikulicic 8a2aa72571 Merge pull request #504 from himanshupsharma/check_fd-setsize
Reverting (socket < 0) checks to avoid Windows build failure.
2015-04-03 11:22:50 +02:00
p_himanshu 7da8f273d2 Reverting (socket < 0) checks to avoid Windows build failure. 2015-04-02 16:47:07 -07:00
Sergey Lyubka a90a5a2b6a Merge pull request #503 from himanshupsharma/check_fd-setsize
Adding a check to avoid undefined behavior if socket is out of the bound...
2015-04-02 18:28:23 +01:00
p_himanshu b5b819b4a3 Adding a check to avoid undefined behavior if socket is out of the bounds of FD_SETSIZE. 2015-04-01 22:24:29 -07:00
Sergey Lyubka 821e2b3a75 Merge pull request #501 from xant/upstream
safety belt : scan_directory() can return without setting arr to a valid value
2015-04-01 20:22:20 +01:00
Sergey Lyubka 773efb0745 Respect WEBSOCKET_OPCODE_CONNECTION_CLOSE coming from client 2015-04-01 18:37:13 +01:00
Andrea Guzzo ed1904a75d safety belt : scan_directory() can return without setting arr to a valid value 2015-03-31 12:52:08 +02:00
Sergey Lyubka a66663f0f6 Fix non-openssl build 2015-03-31 10:38:14 +01:00
Sergey Lyubka 1104688b02 Fix win32 build no2 2015-03-25 17:29:34 +00:00
Sergey Lyubka 36d95e230e Fix win32 build 2015-03-25 17:10:58 +00:00
Sergey Lyubka 8a27a95a2a Fix #460 2015-03-24 09:32:16 +00:00
Sergey Lyubka 2e63b5a5e5 Fix #441 2015-03-24 08:04:46 +00:00
Sergey Lyubka 4cbd113d01 Upload multiple files 2015-03-24 07:52:49 +00:00
Sergey Lyubka ba5ae74144 Merge pull request #495 from mmicko/master
OS2 and Android NDK fixes
2015-03-22 17:03:28 +00:00
Miodrag Milanovic f2b40e5fae added comment for time_t change 2015-03-22 17:56:22 +01:00
Sergey Lyubka 8ed682930b Fix #448 2015-03-21 13:17:24 +00:00
Miodrag Milanovic 86ad7922b0 OS2 and Android NDK fixes
Note that in Android NDK st_mtime is long unsigned int
2015-03-21 11:04:57 +01:00
Sergey Lyubka f7476f53c7 Merge pull request #493 from RobertDiPaolo/bugfix/Visual_Studios_Build_Issues
Correctly handle _CRT_SECURE_NO_WARNINGS already being set in project se...
2015-03-20 16:29:11 +00:00
Sergey Lyubka 5d6f7ac8ef Merge pull request #494 from RobertDiPaolo/bugfix/Memory_Leak
Fixed Memory Leak
2015-03-20 16:28:15 +00:00
Sergey Lyubka f16fa5ed55 Merge pull request #492 from RobertDiPaolo/feature/Add_PATCH_Method
Added PATCH to list of valid HTTP Methods.
2015-03-20 16:28:11 +00:00
Sergey Lyubka c0ba32f7a6 Set NS_DISABLE_THREADS ifndef MONGOOSE_ENABLE_THREADS 2015-03-20 15:33:02 +00:00
Sergey Lyubka 409c12a851 Better logic for port resolving 2015-03-18 17:25:46 +00:00
Sergey Lyubka bcdcbf20ee Release 5.6 2015-03-18 17:25:31 +00:00
Sergey Lyubka 8fc5b5a55f Add contribution section to readme 2015-03-18 15:45:52 +00:00
Robert Di Paolo 7cf28a5623 The 'char *ip' variable was being allocated and zeroed but not being used or freed. 2015-03-18 10:04:08 +00:00
Robert Di Paolo 6668c456ac Correctly handle _CRT_SECURE_NO_WARNINGS already being set in project settings. 2015-03-18 09:56:01 +00:00
Robert Di Paolo 98f2476751 Added PATCH to list of valid HTTP Methods. 2015-03-18 09:48:17 +00:00
Sergey Lyubka faeedb2930 Sync main 2015-03-18 09:37:52 +00:00
Sergey Lyubka c8e8f94ffe Sync main 2015-03-17 17:35:31 +00:00
Sergey Lyubka 22aeb6111b Update ReleaseNotes 2015-03-17 17:01:16 +00:00
Sergey Lyubka 2d1d2e6534 SIZE_MAX is not defined on MSVC6, use (size_t) ~0 2015-03-17 17:00:59 +00:00
Sergey Lyubka 05c88a98fc Introduce -dav_root option 2015-03-17 15:34:56 +00:00
Marko Mikulicic 5224afb946 Merge pull request #485 from dsrosario/fix_remove_double_dots 2015-03-17 16:07:46 +01:00
Dinis Rosário 3bd79c7cd5 Fix remove_double_dots_and_double_slashes removing all the dots leading http server to serve wrong URI
If the uri is something like '/js/...jquery.js', remove_double_dots_and_double_slashes will remove the 3 dots and the http server will serves the /js/jquery.js file.
remove_double_dots_and_double_slashes should check if a dot or double dots is followed by a slash (or backslash) and only remove this to avoid disclosure attack.
2015-03-17 16:04:59 +01:00
Sergey Lyubka c52e0744cb Squashed warnings after size_t change 2015-03-17 13:18:15 +00:00
Sergey Lyubka 6c09c303d0 Merge pull request #456 from sebgod/fix-win32-examples-using-extra
Enable building of example/Makefile on Win32
2015-03-17 11:45:36 +00:00
Sergey Lyubka b6fde06990 Merge pull request #486 from mmicko/master
Compile fix
2015-03-16 16:52:48 +00:00
Miodrag Milanovic af892c9726 compile fix for visual studio 2015-03-14 09:02:25 +01:00
Miodrag Milanovic df7ad13680 Compile fix 2015-03-13 20:15:19 +01:00
Sergey Lyubka 057c2d4b42 Merge pull request #484 from davidmilligan/master
fix compiler warnings for 64 bit compilation
2015-03-10 18:40:16 +00:00
David Milligan 6c9b43bcf5 fix compiler warnings for 64 bit compilation 2015-03-09 20:01:09 -04:00
Sergey Lyubka a91438acae Fix #477 2015-03-09 16:09:05 +00:00
Sergey Lyubka a6fa51dbc2 Merge pull request #481 from cesanta/web_server_ssl
web_server_ssl
2015-03-06 14:39:50 +00:00
Alexander Alashkin 6ceac6c84c web_server_ssl 2015-03-06 15:08:57 +02:00
Sergey Lyubka 288efe3c23 Add -DMONGOOSE_ENABLE_THREADS to other examples 2015-03-06 09:29:56 +00:00
Sergey Lyubka 5207545a8b Add -DMONGOOSE_ENABLE_THREADS to proxy server example 2015-03-06 09:28:27 +00:00
Sergey Lyubka 716d524f9b Add -DMONGOOSE_ENABLE_THREADS to Makefile 2015-03-06 09:25:30 +00:00
Sergey Lyubka a434bab767 Merge pull request #480 from cesanta/polarssl_examples_1
websocket_ssl_proxy sample for polarsll
2015-03-06 09:03:38 +00:00
Alexander Alashkin e9633a8d2d websocket_ssl_proxy 2015-03-06 09:32:08 +02:00
Sergey Lyubka c7b6a6f0ea Added mg_websocket_printf() 2015-03-05 10:54:51 +00:00
Sergey Lyubka 6cdb9f7ed3 Merge pull request #474 from mmicko/master
OS/2 patches by KO Myung-Hun
2015-03-04 17:18:16 +00:00
Sergey Lyubka 4502dd0c86 s/MONGOOSE_NO_THREADS/MONGOOSE_ENABLE_THREADS 2015-03-03 18:59:23 +00:00
Sergey Lyubka 95055f6048 Add winsock2.h include for win32 2015-03-03 18:32:14 +00:00
Sergey Lyubka 2c36532ec4 Merge pull request #465 from doug16rogers/vs9-compile-ipv6
Allow for compilation in Visual Studio with NS_ENABLE_IPV6.
2015-03-03 18:28:07 +00:00
Sergey Lyubka f2b0b9c737 Fix Win32 build in mg_websocket_write() 2015-02-24 13:32:22 +00:00
Sergey Lyubka b3866439a0 Fix mg_create_server() signature 2015-02-24 13:17:11 +00:00
Miodrag Milanovic 4f2205a667 OS/2 patches by KO Myung-Hun
Upstream patch from MAME project
2015-02-24 11:12:09 +01:00
Sergey Lyubka 6cec1d36a8 Merge pull request #463 from CurlyMoo/patch-1
Replace obsolete gethostbyname by getaddrinfo
2015-02-19 11:48:35 +00:00
CurlyMoo 4238370ae1 Check for getaddrinfo availability. 2015-02-19 12:09:34 +01:00
Sergey Lyubka b4924b715e Merge pull request #473 from mmicko/master
Fix for MINGW builds
2015-02-17 16:19:37 +00:00
Miodrag Milanovic 7a0385dcac Fix for MINGW builds 2015-02-17 11:08:23 +01:00
Sergey Lyubka 44a146faf6 SSL fixes 2015-02-16 18:34:07 +00:00
Sergey Lyubka 53a55da7bc Add type cast in ns_out() 2015-02-16 18:19:15 +00:00
Sergey Lyubka bf44277764 Define _XOPEN_SOURCE for MinGW build 2015-02-16 18:17:30 +00:00
Sergey Lyubka a2e1da6e30 Add overflow checks 2015-02-12 19:12:58 +00:00
Sergey Lyubka bef3f85ba8 Merge pull request #466 from 0-wiz-0/master
Only define _XOPEN_SOURCE on Linux.
2015-02-10 18:07:07 +00:00
Thomas Klausner eb72a63cca Only define _XOPEN_SOURCE on Linux.
Fixes the build on NetBSD.

The comment says it's only needed on Linux, and AFAIK Linux
is the only operating system that only adds symbols when it's defined;
others, like NetBSD or Solaris, also hide symbols.

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
2015-01-29 15:02:26 +01:00
Doug Rogers f19bbc73cc Allow for compilation in Visual Studio 9 (2008) with NS_ENABLE_IPV6. 2015-01-29 00:12:35 -05:00
Sergey Lyubka 25326b3b12 net skeleton -> fossa 2015-01-28 12:33:48 +00:00
CurlyMoo 10ee430bfd Add debug line and adapt to styling guide
Replaced tabs with spaces.
2015-01-27 22:55:13 +01:00
CurlyMoo 10d0bfdab4 Replace obsolete gethostbyname by getaddrinfo
This also protect against the latest glibc bug
2015-01-27 22:45:34 +01:00
Sergey Lyubka 6b6637c337 Adopt SSL guide to current way of setting SSL cert. 2015-01-21 17:41:45 +00:00
Sergey Lyubka 878acca213 Removed Lua docs 2015-01-21 17:30:30 +00:00
Sergey Lyubka ace9285966 Updated years 2015-01-19 18:25:14 +00:00
Sergey Lyubka cdc167b0cc Merge pull request #459 from joshcriz/patch-1
Update Makefile
2015-01-19 16:32:24 +00:00
Josh Criz a0dd396b95 Update Makefile
Fixing typo in 'clean' section
2015-01-16 17:59:08 -06:00
Sebastian Godelet 8082501b9c Enable building of example/Makefile on Win32
Adding example/.gitignore to ignore *.exe
Appending -lws2_32 at the end of CFLAGS_EXTRA if running make on
Windows to enable easy compiling under that platform.
Obsoletes pull request #454
2015-01-10 16:41:58 +08:00
Sergey Lyubka e4ad3010be Fix #416 2014-12-30 03:56:29 +00:00
Sergey Lyubka 03a82ef848 Merge pull request #452 from CurlyMoo/patch-2
Typo
2014-12-27 18:25:09 +00:00
CurlyMoo 9459d69dcc Typo 2014-12-27 18:35:09 +01:00
Sergey Lyubka b28662362d Merge pull request #449 from ursine/patch-1
64-bit length fields on ARM don't work
2014-12-21 20:54:52 +00:00
Sergey Lyubka 66450bf3d1 Merge pull request #450 from sebgod/master
mongoose.c: using application/javascript for .js
2014-12-21 16:07:12 +00:00
Sebastian Godelet 478ca05e7a mongoose.c: using application/javascript for .js
As of http://www.rfc-editor.org/rfc/rfc4329.txt, the preferred MIME type
for JavaScript is application/javascript.
2014-12-21 22:16:05 +08:00
Gary Coulbourne 8cad0a72f9 64-bit length fields on ARM don't work
ARM only allows aligned accesses.  GCC generated unaligned accesses for the copy buffer, but ARM forces alignment, causing the first two bytes to be trampled.  I changed the mechanism to create two temporaries and memcpy them in.  It now works on ARM (and x86) for large websocket chunks.
2014-12-17 19:14:30 -05:00
Sergey Lyubka 31178f4d48 Typo fixed in the comment 2014-12-15 12:03:50 +00:00
Sergey Lyubka 7a5485493e Added md5 copyright 2014-12-11 18:01:58 +00:00
Sergey Lyubka d3cbb160f5 Removed travis config file 2014-12-01 11:33:16 +00:00
Sergey Lyubka 45ff2c2c19 Removed $Date$ marker 2014-11-28 14:16:49 +00:00
Sergey Lyubka c3db7b141b Removed $Date$ from header 2014-11-28 12:21:36 +00:00
Sergey Lyubka 0a0ea36ace Fix examples/proxy_server build 2014-11-24 19:33:24 +00:00
Sergey Lyubka 72ed954721 Merge pull request #440 from zapline/patch-1
Update ReleaseNotes.md(spell mistake)
2014-11-20 07:35:24 +00:00
zapline 33e035273a Update ReleaseNotes.md
spell mistake
2014-11-20 09:58:29 +08:00
Sergey Lyubka 223f36c130 Updated Readme 2014-11-17 15:50:02 +00:00
Sergey Lyubka 4c0bc5bd03 Updated Readme 2014-11-17 15:49:37 +00:00
Sergey Lyubka 808a5f6f53 Update README.md 2014-11-13 13:48:43 +00:00
Sergey Lyubka 404e635665 Fixed Android build 2014-11-12 22:16:32 +00:00
Sergey Lyubka 9d7a60a63f Merge pull request #433 from jhnwkmn/malloc
Consistent use of NS_MALLOC, NS_FREE and NS_REALLOC
2014-11-10 10:35:07 +00:00
Johan Wikman ba9c74187b Consistent use of NS_MALLOC, NS_FREE and NS_REALLOC
malloc(), free() and realloc() were used in a number of places.
Added NS_CALLOC as well.
2014-11-10 08:29:19 +02:00
Sergey Lyubka e9d4847cbb Merge pull request #432 from jhnwkmn/o_binary
O_BINARY might be defined.
2014-11-09 10:06:16 +00:00
Sergey Lyubka ea76de07ee Merge pull request #436 from jhnwkmn/no-cgi
MONGOOSE_NO_CGI needs special handling.
2014-11-09 10:04:54 +00:00
Sergey Lyubka 5a8c468ff7 Merge pull request #435 from jhnwkmn/size-macros
Added size macros.
2014-11-09 10:01:59 +00:00
Sergey Lyubka 5b143a6237 Merge pull request #434 from jhnwkmn/no-user
Added MONGOOSE_NO_USER configuration define.
2014-11-09 09:56:31 +00:00
Sergey Lyubka d244a7fdfd Merge pull request #437 from jhnwkmn/nsf-close-immediately
If socket is about to be closed do not add to [read|write]_set.
2014-11-09 09:55:13 +00:00
Johan Wikman 300a27de99 If socket is about to be closed do not add to [read|write]_set.
If NSG_CLOSE_IMMEDIATELY is on, then the socket will be closed,
which means that (if the socket was added to either read_set or
write_set) the subsequent select will in turn be performed on a
socket that has been closed.

Standard socket implementations seem to ignore a descriptor
referring to a closed socket but LWIP
(http://savannah.nongnu.org/projects/lwip/) crashes. So better
not to add to the sets.
2014-11-07 15:48:23 +02:00
Johan Wikman 04a15a0c10 MONGOOSE_NO_CGI needs special handling.
MONGOOSE_NO_CGI is implied by both NS_DISABLE_SOCKETPAIR and
MONGOOSE_NO_FILESYSTEM. Thus, so as not to get complaints about
the same define being defined twice, some extra checks are needed.
2014-11-07 15:29:25 +02:00
Johan Wikman f0f6ae05aa Added size macros.
On very resource constraind devices you need to be able to
control the size of all buffers and structures placed on the
stack.
2014-11-07 14:31:44 +02:00
Johan Wikman 8a7d535d92 Added MONGOOSE_NO_USER configuration define.
Low-end systems, not running a proper OS, may not have the
concept of a user.
2014-11-07 14:01:13 +02:00
Sergey Lyubka e7ac6024de Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-11-07 10:05:51 +00:00
Sergey Lyubka 9981b99ac8 Extra NULL check in iter2(). Fix #430 2014-11-07 10:05:42 +00:00
Johan Wikman 87a36c0c30 O_BINARY might be defined.
Some unix environments defines O_BINARY.
2014-11-07 12:02:11 +02:00
Sergey Lyubka f2b13761c0 Merge pull request #431 from jhnwkmn/reduce-includes
Conditionally include dirent.h and dlfcn.h
2014-11-07 09:51:30 +00:00
Johan Wikman 9786478a31 Conditionally include dirent.h and dlfcn.h
If you do not have a filesystem or do not support dav or
dynamic loading, the corresponding header files need not
be included (some environments might not have them).
2014-11-07 11:05:51 +02:00
Sergey Lyubka 7d236d7f33 Merge pull request #429 from AlexAltea/master
Added #define's for deprecated POSIX names
2014-11-01 20:39:34 +00:00
Alexandro Sánchez Bach e098a7292d Added #define's for deprecated POSIX names 2014-10-30 23:07:48 +01:00
Sergey Lyubka 632b3a38a9 5.5 -> 5.6 2014-10-28 11:43:51 +00:00
Sergey Lyubka 23141c2fef Added 5.5 release notes 2014-10-28 11:42:47 +00:00
Sergey Lyubka c8ba652f1c 5.4 -> 5.5 2014-10-28 11:20:44 +00:00
Sergey Lyubka 6ac2fa2ae6 Updated listening_port for SSL option 2014-10-28 11:20:10 +00:00
Sergey Lyubka 0322ec5647 Include query_string when proxying requests 2014-10-22 12:14:21 +01:00
Sergey Lyubka a5223a9850 Squashed ARM warnings 2014-10-21 15:51:42 +01:00
Sergey Lyubka 016968ada1 Removed net_skeleton dependency from examples/proxy_server 2014-10-17 20:29:39 +01:00
Sergey Lyubka 710b888122 Added -pthread to test/Makefile::CFLAGS 2014-10-17 20:12:29 +01:00
Sergey Lyubka cf53959f34 Fix broken push (type cast) 2014-10-17 20:03:15 +01:00
Sergey Lyubka 30d29fb77f Merge pull request #425 from mpromonet/master
make compile with g++ (fix invalid cast from ‘void*’)
2014-10-17 19:49:59 +01:00
MPR c05b51bbfc make compile with g++ (fix invalid conversion from ‘void*’ to ‘ns_connection*’) 2014-10-16 23:57:14 +02:00
Sergey Lyubka 1ab704ac92 Fixed -DMONGOOSE_NO_DIRECTORY_LISTING build 2014-10-16 10:46:33 +01:00
Sergey Lyubka 2bc77e065c Fixed build 2014-10-15 14:29:22 +01:00
Sergey Lyubka 790daabf7d Enhanced RESTful API example 2014-10-15 11:58:47 +01:00
Sergey Lyubka a6598a1278 Added #define close(x) _close(x) for WIN32 to squash warning 4996 that VS2013 gives 2014-10-15 08:30:49 +01:00
Sergey Lyubka 0af5502b74 Removed redundant #defines for -D_WIN32 case 2014-10-15 08:28:17 +01:00
Sergey Lyubka f059e41cac Removed mg_set_listening_socket() and mg_get_listening_socket(), added mg_copy_listeners() 2014-10-14 15:25:56 +01:00
Sergey Lyubka 2cce91de9a Refactored code for multiple listeners 2014-10-14 14:22:26 +01:00
Sergey Lyubka 0ff5b5b044 Added support for multiple listeners 2014-10-14 13:59:22 +01:00
Sergey Lyubka 0c5d9a98c2 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-10-14 11:10:47 +01:00
Sergey Lyubka c9fbdfc1b5 mg_open() accepts 3rd param: mode 2014-10-14 11:10:42 +01:00
Sergey Lyubka 6193b5171c Merge pull request #421 from mpromonet/master
transmit http answer code using http_client
2014-10-14 11:10:03 +01:00
Sergey Lyubka 911115ccc0 Added -pthread to CFLAGS for linux 2014-10-14 10:05:12 +00:00
Sergey Lyubka 2f3ddeccc5 Properly trim whitespaces from the hashbang CGI interpreter path 2014-10-13 15:57:34 +01:00
MPR ca3f5a3257 follow Google style 2014-10-12 13:58:06 +02:00
MPR df206bc05a transmit http answer code using http_client 2014-10-11 17:56:35 +02:00
Sergey Lyubka 531fec34fd Added missing files 2014-10-10 14:35:39 +01:00
Sergey Lyubka 4c10d1f356 mongoose_server -> web_server 2014-10-10 13:58:45 +01:00
Sergey Lyubka 94dccdd6f4 c# -> csharp 2014-10-10 10:02:58 +01:00
Sergey Lyubka 544352b7d3 moved jni to android_build 2014-10-10 09:51:57 +01:00
Sergey Lyubka 29c2ae4886 moved multi_threaded to separate dir 2014-10-10 09:51:02 +01:00
Sergey Lyubka 1a2e2ec2fd moved proxy to separate dir 2014-10-10 09:48:43 +01:00
Sergey Lyubka 3e780d21fc moved form.c example to separate dir 2014-10-10 09:44:45 +01:00
Sergey Lyubka 63fcea0159 moved form_submit to separate dir 2014-10-10 09:40:07 +01:00
Sergey Lyubka e5d21225be moved big_upload to separate dir 2014-10-10 09:39:12 +01:00
Sergey Lyubka 0c9caf3120 Moved server.c to separate dir 2014-10-10 09:37:18 +01:00
Sergey Lyubka 54ba36c1c9 check_login_form_submission() factored in separate function 2014-10-09 11:44:12 +01:00
Sergey Lyubka 5077350589 Added cookie based auth example 2014-10-09 11:29:39 +01:00
Sergey Lyubka 2d880c4f5c Moved auth.c to separate dir 2014-10-09 09:42:07 +01:00
Sergey Lyubka 4ca4c862a5 Updated net_skeleton, added extra_headers param to mg_send_file() 2014-10-09 09:26:45 +01:00
Sergey Lyubka 0918df1566 Removed reference to chat.c 2014-10-05 17:29:33 +01:00
Sergey Lyubka aa2583cc26 Added enable_proxy 2014-10-03 11:54:00 +01:00
Sergey Lyubka e1b1d39635 Removed conflicting MIT-related comment block 2014-10-01 12:11:04 +01:00
Sergey Lyubka 3bf82dd541 Merge pull request #419 from grodansparadis/master
connection_data -> user_data
2014-09-22 15:03:19 +01:00
Sergey Lyubka 2896965c97 Fixed link to examples 2014-09-20 08:32:29 +01:00
Ake Hedman 53b784b143 connection_data -> user_data 2014-09-19 08:20:37 +02:00
Sergey Lyubka 8e91e3a305 Timeout only non-listening connections 2014-09-16 07:47:40 +01:00
Sergey Lyubka dbc07c8b00 Moved mjpg_streamer to a separate dir 2014-09-15 19:05:30 +01:00
Sergey Lyubka ce953575e2 Not closing listening connections 2014-09-15 13:48:55 +01:00
Sergey Lyubka 80db048578 Added more dependencies in test/Makefile 2014-09-15 01:28:03 +01:00
Sergey Lyubka 382d165574 Added MONGOOSE_NO_MMAP conditional 2014-09-15 01:18:38 +01:00
Sergey Lyubka 0fb2f38cb7 Fixed mg_connect() call 2014-09-14 15:06:09 +01:00
Sergey Lyubka aa007f1285 Updated travis config 2014-09-11 15:55:18 +01:00
Sergey Lyubka 8752910330 Better UDP support 2014-09-11 15:52:42 +01:00
Sergey Lyubka 2a5a8eec49 removed chat_server dir in examples 2014-09-10 00:59:31 +01:00
Sergey Lyubka ceca52de30 Moved file send_file example to separate dir 2014-09-09 23:23:29 +01:00
Sergey Lyubka 8a3691055c Moved file upload example to separate dir 2014-09-09 23:20:23 +01:00
Sergey Lyubka 56d12c89da Typo in hello_world.c fixed 2014-09-09 22:47:07 +01:00
Sergey Lyubka 2cfce4d8b2 Added copyright 2014-09-09 22:46:24 +01:00
Sergey Lyubka f372faf614 Moved hello.c example to its own dir 2014-09-09 22:44:57 +01:00
Sergey Lyubka 882f3b3ac3 removed hello.lp 2014-09-09 18:26:03 +01:00
Sergey Lyubka fac0e9b0ac Moved unit test to dedicated dir 2014-09-09 18:23:48 +01:00
Sergey Lyubka a3cf67c380 Moved examples/mkdata.pl -> scripts/embed_binary_files.pl 2014-09-09 18:11:57 +01:00
Sergey Lyubka 2987cbdb5c ws_ssl -> websocket_ssl_proxy 2014-09-09 18:09:33 +01:00
Sergey Lyubka 6083b9c5c5 Updated to the recent skeleton. SSL address format changed 2014-09-09 18:07:55 +01:00
Sergey Lyubka 83237a02d9 Made local copies of dependencies 2014-09-09 17:03:50 +01:00
Sergey Lyubka 965188bac9 removed chat.c 2014-09-09 17:01:06 +01:00
Sergey Lyubka 66da41d401 Adopted to the recent net_skeleton 2014-09-09 17:00:49 +01:00
Sergey Lyubka cfd334ac6c Moved websocket echo server example 2014-09-09 09:27:35 +01:00
Sergey Lyubka b5f6254c1e Added date marker 2014-09-08 23:30:52 +01:00
Sergey Lyubka dcbd1cbbd1 Moved pubsub example to websocket_chat 2014-09-08 23:29:34 +01:00
Sergey Lyubka a3b568f460 removed lua_ddl.c 2014-09-08 23:22:46 +01:00
Sergey Lyubka 75770aec80 Merge pull request #415 from mmicko/master
Added mg_mmap and mg_munmap utility functions for memory mapping files
2014-09-07 11:55:27 +01:00
Sergey Lyubka 3a8ae7ac17 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-09-06 10:11:43 +01:00
Sergey Lyubka b116b2fa82 mg_poll_server doc corrected 2014-09-06 10:10:22 +01:00
m.milanovic@levi9.com 7806609773 Added mg_mmap and mg_munmap utility functions for memory mapping files 2014-09-04 15:05:42 +02:00
Sergey Lyubka 72f45aa7e2 Merge pull request #414 from mmicko/master
Fixed compile on varois MINGW versions
2014-09-02 12:34:58 +01:00
m.milanovic@levi9.com 5e3e6a6dce Fixed compile on MINGW so it is confirmed working on versions 4.6.x till 4.9.x 2014-09-02 12:11:21 +02:00
Sergey Lyubka 1388bb1db4 Fixed line endings 2014-09-01 21:02:16 +01:00
Sergey Lyubka 3cc0d16f65 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-09-01 20:55:37 +01:00
Sergey Lyubka b50095fa61 Added $Date$ markers 2014-09-01 20:54:12 +01:00
Sergey Lyubka 7ad85219d8 Merge pull request #413 from mcallegari/master
Fixed build warning of signed/unsigned conditional expression
2014-08-30 12:42:09 +01:00
Massimo Callegari 347a249d10 Fixed build warning of signed/unsigned conditional expression 2014-08-30 13:04:11 +02:00
Sergey Lyubka 07d982129a Passing NS events together with the NC pointer 2014-08-29 23:28:34 +01:00
Sergey Lyubka 73f2602ba0 Updated due to ssl_wrapper.h refactoring 2014-08-26 14:42:24 +01:00
Sergey Lyubka 44561d163a updated travis config 2014-08-22 22:39:48 +01:00
Sergey Lyubka c941a1a39a Proper struct mg_connection cleanup in close_local_endpoint() 2014-08-22 16:26:30 +01:00
Sergey Lyubka bee22312bc removed dead code 2014-08-21 04:13:33 +01:00
Sergey Lyubka bdb16c624c Added MG_RECV event and mg_send_file_data() func 2014-08-21 04:09:06 +01:00
Sergey Lyubka e389e70d05 squashed warn in mg_terminate_ssl() 2014-08-20 21:54:09 +01:00
Sergey Lyubka 695559f691 Updated to the latest SSL wrapper 2014-08-13 09:17:20 +01:00
Sergey Lyubka 13be74b4c6 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-08-11 16:20:25 +01:00
Sergey Lyubka 02a1032fd4 updated ssl_wrapper 2014-08-11 16:19:25 +01:00
Sergey Lyubka 788f35b19c Merge pull request #411 from mmicko/master
Make mongoose compile on mingw environment
2014-08-11 15:01:33 +01:00
Miodrag Milanovic 3721efe1e9 Make mongoose compile on mingw environment 2014-08-11 15:27:23 +02:00
Sergey Lyubka e0822ffb78 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-08-08 14:25:58 +01:00
Sergey Lyubka ae7d5a8f94 Bumping up default timeout from 30 to 300 sec 2014-08-08 14:25:44 +01:00
Sergey Lyubka ced7a2e0b5 Merge pull request #410 from zinosat/avoid_largefile_redefinition
Avoid unconditional definition of _LARGEFILE_SOURCE
2014-08-07 22:13:09 +01:00
Davide Viti 5ed6708468 Avoid unconditional definition of _LARGEFILE_SOURCE
On some build systems (i.e. Buildroot), _LARGEFILE_SOURCE is defined
at "higher level" as default CFLAG definition.
This fix avoids the following compilation warning:

mongoose-5.4/mongoose.c:52:0: warning: "_LARGEFILE_SOURCE" redefined [enabled by default]
 #define _LARGEFILE_SOURCE       // Enable fseeko() and ftello() functions
 ^
<command-line>:0:0: note: this is the location of the previous definition
2014-08-07 22:08:12 +02:00
Sergey Lyubka 9fe53f307b Added http client example 2014-08-05 17:14:41 +01:00
Sergey Lyubka c64d30e1f6 removed make_settings.mak 2014-08-05 16:41:14 +01:00
Sergey Lyubka b4c25fc7ba Added ALL_PROGS 2014-08-05 16:40:51 +01:00
Sergey Lyubka b67b618811 Added guard for MONGOOSE_NO_FILESYSTEM 2014-08-04 22:32:24 +01:00
Sergey Lyubka 5a19438f70 Added guard for MONGOOSE_NO_FILESYSTEM 2014-08-04 22:31:59 +01:00
Sergey Lyubka 860addf1e3 MONGOOSE_NO_SOCKETPAIR -> NS_DISABLE_SOCKETPAIR 2014-08-03 18:56:19 +01:00
Sergey Lyubka 03d571a119 Merge pull request #407 from kuiash/master
Populate HTTP warning codes
2014-08-03 18:29:15 +01:00
Sergey Lyubka 0d9ecffc53 Do not dealloc conn->request in mg_forward() 2014-08-03 12:41:15 +01:00
Daniel O'Connell d4c8384b85 ws_ssl example 2014-08-03 12:40:10 +01:00
Sergey Lyubka bd40145301 moved hex dumping to skeleton 2014-08-01 17:35:59 +01:00
Sergey Lyubka 9b42494316 Added general example makefile settings 2014-08-01 13:30:05 +01:00
Sergey Lyubka 2daff6959f Added #define matrix 2014-08-01 09:11:00 +01:00
Sergey Lyubka e9c434a6a1 updated net skeleton 2014-08-01 09:05:50 +01:00
Sergey Lyubka d6fba7e45d Added travis file 2014-08-01 08:08:54 +01:00
Sergey Lyubka 0a0130b90c removed 2014-08-01 07:53:51 +01:00
Sergey Lyubka facf2af66e Clearing off HTTP headers in close_local_endpoint() 2014-07-31 20:05:25 +01:00
Sergey Lyubka cc54195f59 Added mg_forward() 2014-07-31 20:04:59 +01:00
Sergey Lyubka e2fb707d9f Added SSL_CTX_set_mode() 2014-07-30 11:27:37 +01:00
kuiash 7dfff935d6 Populate HTTP warning codes
Includes changing 201 "Server Error" to "Internal Server Error"
List mostly borrowed from here http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
418 and 451 also added
Local testing showed a problem with 202 reported as "Server Error" instead of "Accepted"
2014-07-29 12:48:22 +01:00
Sergey Lyubka 5727a5c0ed Removed lua examples 2014-07-29 07:39:20 +01:00
Sergey Lyubka 268d2e9cbe better explanation for websocket2.c example 2014-07-28 12:19:00 +01:00
Sergey Lyubka 1e7da874a4 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-07-28 12:15:23 +01:00
Sergey Lyubka 7875a8c2bd release notes for 5.4 2014-07-28 12:15:13 +01:00
Sergey Lyubka b0355d45ae Merge pull request #403 from pavel-pimenov/fix-cache-call-stat
stat - function result cache
2014-07-27 11:13:26 +01:00
Sergey Lyubka 91136d7731 Merge pull request #406 from Cykey/master
Set the correct json content-type
2014-07-27 11:12:52 +01:00
Pavel Pimenov 01a058d29b Remove file_stat_t st_cgi; 2014-07-27 13:10:49 +04:00
Pavel Pimenov e6eca1738f 80 characters limit + remove tabs 2014-07-27 12:53:37 +04:00
Pavel Pimenov 2108ec5a0c Fix style for pointer 2014-07-27 12:44:08 +04:00
David M. bc4e47630a Set the correct json content-type
Chance text/json to application/json to comply with the RFC.

See http://www.ietf.org/rfc/rfc4627.txt for more information.
2014-07-26 20:55:59 -04:00
Pavel Pimenov f41c9a2a1f stat - function result cache 2014-07-23 11:26:20 +04:00
Sergey Lyubka 6c77208236 release notes dates 2014-07-21 21:38:45 +01:00
Sergey Lyubka 386d2e5cd4 fix leak in handle_propfind() 2014-07-18 13:00:43 +01:00
Sergey Lyubka b738fdbffa updated net skeleton 2014-07-08 11:28:03 +01:00
Sergey Lyubka b5704850db Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-07-08 11:10:17 +01:00
Sergey Lyubka 9c67e8960e updated certs 2014-07-08 11:10:08 +01:00
Sergey Lyubka d3dff4e1d5 Merge pull request #391 from pavel-pimenov/pvs-studio-fix-zu
Change printf mask %zu -> %lu
2014-07-07 08:58:23 +01:00
Pavel Pimenov 82872e86fd Change printf mask %zu -> %lu
for MS VC++ compatibility http://stackoverflow.com/questions/15610053/correct-printf-format-specifier-for-size-t-zu-or-iu
2014-07-07 09:24:48 +04:00
Sergey Lyubka ac229b6606 Merge pull request #387 from Z-Wave-Me/master
Disallow WebDAV MKCOL/PUT/DELETE requests to protected files
2014-06-28 21:40:11 +01:00
Alex Skalozub a6bf2bcbf4 Should also disallow PROPFIND as well 2014-06-29 00:03:52 +04:00
Alex Skalozub b0cf8304cb Disallow WebDAV MKCOL/PUT/DELETE requests to protected files (like .htpasswd) 2014-06-28 23:14:21 +04:00
Sergey Lyubka 0d9fe39dbb ns_read_from_socket(): calling recv() in a loop until failure 2014-06-25 11:43:07 +01:00
Sergey Lyubka 708af6d9c5 more comments in big_upload.c 2014-06-24 17:09:00 +01:00
Sergey Lyubka e4c71425c9 Added big_upload.c 2014-06-24 17:04:26 +01:00
Sergey Lyubka 6e07215c1c Using Multiple inputs for upload example 2014-06-24 16:35:59 +01:00
Sergey Lyubka ca9603301e removed trailing newline 2014-06-24 16:35:26 +01:00
Sergey Lyubka d6c388042c QNX SSL upload fix 2014-06-23 13:52:07 +01:00
Sergey Lyubka 6f66d794e8 Refactor NS_POLL case in mg_ev_handler 2014-06-20 11:41:13 +01:00
Sergey Lyubka 1389eec784 Added comment for mg_terminate_ssl() call 2014-06-19 09:55:10 +01:00
Sergey Lyubka 6ef795e082 manual mitm for oracle.com 2014-06-19 09:53:38 +01:00
Sergey Lyubka 1e5d258e9e Wording for licensing clarified 2014-06-18 11:30:57 +01:00
Sergey Lyubka 70eb4c4bbc exported mg_terminate_ssl 2014-06-18 10:59:29 +01:00
Sergey Lyubka a639e10a4d squash QNX warning about execle() call 2014-06-17 13:28:45 +01:00
Sergey Lyubka 48750e67f6 ENABLE_PROXY is visible with MONGOOSE_NO_FILESYSTEM 2014-06-17 10:50:47 +01:00
Sergey Lyubka ce60379af6 sending 405 for proxy request if connect is not allowed 2014-06-16 11:27:17 +01:00
Sergey Lyubka e0b9e4abfd Added enable_proxy 2014-06-16 11:06:57 +01:00
Sergey Lyubka 665f205527 squash warning under mingw 2014-06-16 10:46:50 +01:00
Sergey Lyubka 030daaf5d5 squash warning under mingw 2014-06-16 10:44:56 +01:00
Sergey Lyubka 760511ec49 squashed warning around NS_STACK_SIZE 2014-06-16 10:21:31 +01:00
Sergey Lyubka 203688a34b Added comment for Win32 SO_RESUSEADDR 2014-06-13 10:19:46 +01:00
Sergey Lyubka 29f4703e4f Adding zero-length chunk for long-running requests 2014-06-13 07:57:27 +01:00
Sergey Lyubka 3cec6f6745 keeping alive long-lived connections 2014-06-12 10:58:49 +01:00
Sergey Lyubka abcea07641 Fix #373 2014-06-11 20:37:35 +01:00
Sergey Lyubka 6a54704b29 mg_set_option(): always set correct actual listening port 2014-06-11 20:12:23 +01:00
Sergey Lyubka 8a2fbac4c0 Calling event handler in MITM mode before making connection to the target host 2014-06-11 09:56:34 +01:00
Sergey Lyubka 96ce6bac69 ns_server_poll(): setting current_time to now after select() 2014-06-11 09:44:18 +01:00
Sergey Lyubka 50c0b958ff Added -root cmd line flag to proxy example 2014-06-10 12:22:50 +01:00
Sergey Lyubka 44416902d6 Changed debug in do_proxy() 2014-06-10 12:22:30 +01:00
Sergey Lyubka 25e646c1a1 Squashed warnings for MONGOOSE_NO_FILESYSTEM 2014-06-10 10:26:58 +01:00
Sergey Lyubka bd723bdc38 Removed dead code in websocket2.c 2014-06-09 17:33:26 +01:00
Sergey Lyubka 5e57031724 Added pubsub example 2014-06-09 17:26:22 +01:00
Sergey Lyubka c583913290 Added pubsub example 2014-06-09 17:25:08 +01:00
Sergey Lyubka 870ca615de Added mg_next() 2014-06-09 17:24:51 +01:00
Sergey Lyubka 64b51699f8 Added MG_WS_CONNECT 2014-06-09 16:32:56 +01:00
Sergey Lyubka 50a889dac0 Inlined parse_url() 2014-06-04 12:32:47 +01:00
Sergey Lyubka 0ff0788458 Formatting change for mg_send_file() 2014-06-04 12:32:31 +01:00
Sergey Lyubka fec6009edb mg_send_file() doc changed 2014-06-03 18:49:17 +01:00
Sergey Lyubka c4f172a120 Documented mg_send_file() 2014-06-03 18:45:37 +01:00
Sergey Lyubka 464c77314d Amended file sending example 2014-06-03 18:03:13 +01:00
Sergey Lyubka f51ca8d5d1 Added mg_send_file(). Changed sending function to return send_iobuf length. 2014-06-03 18:02:55 +01:00
Sergey Lyubka 7b37e0cb8b Added simplistic flow control in transfer_file_data() 2014-06-03 17:00:52 +01:00
Sergey Lyubka c7925353e7 Added parens around expression to squash warning under QNX SDP 6.6.0 2014-06-03 14:25:54 +01:00
Sergey Lyubka bd23ec4323 Removed a bit of dead code. Added more comments in proxy_event_handler() 2014-05-29 17:40:06 +01:00
Daniel O'Connell 3671b2632d proxy unit test reference implementation 2014-05-29 17:04:28 +01:00
Daniel O'Connell 25115a694c proxy support changes 2014-05-29 17:04:13 +01:00
Sergey Lyubka 2436f9d6c3 squashed win32 warnings 2014-05-22 07:31:19 +01:00
Sergey Lyubka 2238951c18 Integrated Dans net skeleton changes 2014-05-21 16:18:21 +01:00
Daniel O'Connell f266dd2c94 Removed noisy debug messages 2014-05-20 16:40:47 +01:00
Daniel O'Connell b03358cb03 Fixes for the proxy code 2014-05-19 19:08:02 +01:00
Sergey Lyubka 1bede7e28b Added test for parse_url() 2014-05-19 12:56:07 +01:00
Sergey Lyubka 3536670b82 re-worded FAQ section 2014-05-18 16:13:04 +01:00
Daniel O'Connell 3235c05fd6 Added proxy functionality 2014-05-18 13:22:33 +01:00
Daniel O'Connell 63db54e7b5 Added AV faq 2014-05-18 10:53:54 +01:00
Daniel O'Connell 1db51eb788 Moved sse.html to proxy_web_root/index.html 2014-05-13 14:51:16 +01:00
Daniel O'Connell 0e640ae885 Made setopt() wrapper around mg_set_option() 2014-05-13 13:02:08 +01:00
Daniel O'Connell 1bff6df2a7 Enabled SSL for proxy example 2014-05-13 12:33:27 +01:00
Daniel O'Connell d0e66de225 Re-added ssl_ca_certificate option 2014-05-13 12:30:30 +01:00
Daniel O'Connell f537670ce2 Synced net skeleton 2014-05-13 12:28:39 +01:00
Daniel O'Connell 4cb3341a15 Added proxy example, with SSE html page 2014-05-13 11:22:31 +01:00
Daniel O'Connell d52d9a4a6f Added pem files 2014-05-13 11:08:18 +01:00
Daniel O'Connell 4a076c7ea4 Added proxy to the clean target 2014-05-13 10:56:32 +01:00
Sergey Lyubka db6e883c22 Added mg_wakeup_server_ex(), removed mg_wakeup_server() and mg_iterate_over_connections() 2014-05-13 09:33:10 +01:00
Sergey Lyubka 804da054b5 Removed extra line in the comment 2014-05-12 23:24:03 +01:00
Sergey Lyubka fb4e701545 Added mg_wakeup_server_ex() for pushing data 2014-05-12 23:22:57 +01:00
Sergey Lyubka ccff4abf13 Added proxy target 2014-05-12 10:47:08 +01:00
Sergey Lyubka 24a7936907 Squashed warning for non-ssl case in ns_set_ssl_ca_cert() 2014-05-11 16:05:07 +01:00
Sergey Lyubka 0993994139 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-05-11 13:43:10 +01:00
Sergey Lyubka 8b740536de Added ssl_ca_certificate option 2014-05-11 13:42:59 +01:00
Sergey Lyubka e851aac853 Merge pull request #371 from cry-inc/master
Fixed wrong behavior of mg_set_option() with option "listening_port" caused by SO_REUSEADDR when using Windows
2014-05-07 17:00:36 +01:00
cry-inc a39861b7bf Fixed wrong behavior of mg_set_option() with option "listening_port" caused by SO_REUSEADDR when using Windows 2014-05-07 16:38:23 +02:00
Sergey Lyubka 63490249ba Merge pull request #368 from cry-inc/master
Fixed wrong MIME type for .rar files
2014-04-30 10:45:09 +01:00
cry-inc 704f057384 Fixed wrong MIME type for .rar files 2014-04-30 10:30:35 +02:00
Sergey Lyubka 40968bc496 Moved other products in a different section 2014-04-30 09:18:55 +01:00
Sergey Lyubka 6873f3c5f6 Removed idle_timeout_ms 2014-04-29 18:01:25 +01:00
Sergey Lyubka ba5cd7267a Added MONGOOSE_SEND_NS_EVENTS to the embedding doc 2014-04-28 15:04:39 +01:00
Sergey Lyubka 1bb98e5e8e Exported mg_websocket_printf(), mg_url_encode(). Added unit test for mg_url_encode() 2014-04-25 18:04:24 +01:00
Sergey Lyubka a7774d0f1a Added mg_websocket_printf(). added MONGOOSE_SEND_NS_EVENTS 2014-04-24 14:09:54 +01:00
Sergey Lyubka f52c756fbb Calling SSL_free() in ns_close_conn() 2014-04-16 16:45:31 +01:00
Sergey Lyubka cc586c6ba2 php->basic 2014-04-15 14:13:38 +01:00
Sergey Lyubka 606eab7f4f Passing PUT content to the event handler 2014-04-14 16:14:13 +01:00
Sergey Lyubka 872b85b5f2 more on -access_control_list 2014-04-14 13:03:47 +01:00
Sergey Lyubka 35bd2b6032 Added form.c 2014-04-10 22:18:01 +01:00
Sergey Lyubka c5287b9044 iobuf_append() refactored: allocating exactly as many bytes as needed 2014-04-09 23:52:16 +01:00
Sergey Lyubka 223f6d960e README message changed 2014-04-09 18:10:49 +01:00
Sergey Lyubka 464b895116 Added enum for websocket opcodes 2014-04-09 15:16:03 +01:00
Sergey Lyubka 05d7b7c8bc Added MG_WS_HANDSHAKE 2014-04-09 11:55:36 +01:00
Sergey Lyubka d8b4db37a0 Squashed warnings 2014-04-09 11:37:08 +01:00
Sergey Lyubka 6bb49c780c Updated net skeleton code 2014-04-09 11:32:23 +01:00
Sergey Lyubka 3a60c5764d Unit test target corrected 2014-04-07 19:07:41 +01:00
Sergey Lyubka a8b38e4ab9 mg_set_option() sets NULL if value is empty 2014-03-31 15:02:20 +01:00
Sergey Lyubka 8750f8af1f Added cast in try_parse() 2014-03-31 09:51:47 +01:00
Sergey Lyubka e94a02dc12 Added more in 5.4 release notes 2014-03-31 09:49:42 +01:00
Sergey Lyubka 5680b0fcc5 Removed redundant cast in try_parse() 2014-03-31 09:34:31 +01:00
Sergey Lyubka 33c56b0edc Init local_ip and local_port properly in mg_connection 2014-03-30 22:50:10 +01:00
Sergey Lyubka e62e48397d Keeping absolute path for config file 2014-03-30 16:00:03 +01:00
Sergey Lyubka 8be30350be mg_set_option(): allow NULL as value. Fast success if old_value == new_value. 2014-03-30 15:59:39 +01:00
Sergey Lyubka 2609a2ab72 Fixed comment for mg_template() 2014-03-30 12:47:27 +01:00
Sergey Lyubka 5a04ab2c56 Added mg_template() function 2014-03-30 12:45:48 +01:00
Sergey Lyubka 4739de6c28 Removed DLL interface and Lua conditional 2014-03-30 12:34:32 +01:00
Sergey Lyubka 639d7a2fd8 Fixing MinGW compilation: pid_t -> process_id_t 2014-03-28 09:18:38 +00:00
Sergey Lyubka 8115ce1d82 Handling SSL_write() error 2014-03-27 11:18:20 +00:00
Sergey Lyubka 3558b587b7 Fixed linking problem for -DMONGOOSE_NO_FILESYSTEM 2014-03-27 10:13:34 +00:00
Sergey Lyubka e21ec58ea8 dav fixes: using auth if auth file is set 2014-03-26 23:13:14 +00:00
Sergey Lyubka 74135bca7d link fixed 2014-03-26 18:58:58 +00:00
Sergey Lyubka d369f31608 return 404 for non-existent propfind URIs 2014-03-26 16:34:55 +00:00
Sergey Lyubka d4b14ca3c1 Better API documentation 2014-03-26 14:13:30 +00:00
Sergey Lyubka f0994896d5 FileSharing doc nitpick 2014-03-26 12:27:44 +00:00
Sergey Lyubka cfdd430b98 Added hexdump_file option 2014-03-26 12:20:02 +00:00
Sergey Lyubka a6c05a9e83 changed handle_propfind() to report only dir entry when listing dir 2014-03-24 20:39:32 +00:00
Sergey Lyubka 94f63787bb Restored void * parameter for iterate_over_connections() 2014-03-24 16:01:45 +00:00
Sergey Lyubka 367f5df328 match_prefix -> mg_match_prefix 2014-03-24 16:00:17 +00:00
Sergey Lyubka f096138d6e Added release note 2014-03-23 20:02:41 +00:00
Sergey Lyubka 0d00cd51e6 Fix #356 2014-03-23 19:59:03 +00:00
Sergey Lyubka b216210a13 Moving lua server side to server.c 2014-03-23 15:33:39 +00:00
Sergey Lyubka 166833f330 Added release notes 2014-03-21 11:47:52 +00:00
Sergey Lyubka 4d6bedfd4e Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-03-20 15:01:18 +00:00
Sergey Lyubka ace8c1736c Added mg_load_dll() 2014-03-20 15:01:05 +00:00
Sergey Lyubka c658a54d18 changed set_absolute_path() signature 2014-03-20 14:58:37 +00:00
Sergey Lyubka 781a1dc25e Merge pull request #352 from ranzhengyuan/some-idea
I think that when the socket invalid, the return value should be -1.
2014-03-20 10:34:18 +00:00
冉正源 3ea3b8dfa4 I think that the socket is invalid, the return should be -1. 2014-03-19 22:32:41 +08:00
Sergey Lyubka a514e143ff updated faw and tutorials 2014-03-19 11:41:01 +00:00
Sergey Lyubka e1486a79e3 Merge pull request #350 from solomonhuang/nodav
Remove MONGOOSE_NO_DAV on DAV_AUTH_FILE options
2014-03-19 11:25:15 +00:00
Sergey Lyubka ee615248e3 Merge pull request #351 from da4089/master
Tyop fix.
2014-03-19 09:33:58 +00:00
David Arnold 687e0e2ee8 Tyop fix. 2014-03-19 04:49:47 +00:00
Solomon Huang 19aefcb7dd Remove MONGOOSE_NO_DAV on DAV_AUTH_FILE options
Building with -DMONGOOSE_NO_DAV will fail.
2014-03-19 01:53:02 +08:00
Sergey Lyubka 6a46244a21 embedding guide for MG_POLL fixed 2014-03-14 08:19:54 +00:00
Sergey Lyubka 60674c11c9 API docs regarding MG_POLL changed 2014-03-13 12:23:53 +00:00
Sergey Lyubka 91c9ab807b Forwarding POST data to the CGI process 2014-03-12 22:43:04 +00:00
Sergey Lyubka 9231c7346c match_prefix -> mg_match_prefix 2014-03-12 18:35:36 +00:00
Sergey Lyubka 20cb3a823a Added ecos & qnx 2014-03-12 14:19:36 +00:00
Sergey Lyubka cbd8d69e6d Added hello world for Lua 2014-03-12 12:47:41 +00:00
Sergey Lyubka f7fcfa6a42 Fixed C# example to work with 5.3 2014-03-12 12:31:53 +00:00
Sergey Lyubka 293c5e5852 Moved screenshots down 2014-03-11 16:59:17 +00:00
Sergey Lyubka ceb866b4ee Using img tags for screenshots 2014-03-11 16:57:38 +00:00
Sergey Lyubka 2f9166e96e Added screenshots for mongoose 2014-03-11 16:51:54 +00:00
Sergey Lyubka fe0e0e69e5 File sharing tutorial wording 2014-03-11 15:36:23 +00:00
Sergey Lyubka db96641c10 Added logo 2014-03-11 06:13:59 +00:00
Sergey Lyubka fe83928ca4 Added logo 2014-03-11 06:11:56 +00:00
Sergey Lyubka 014414f17f Docs links made separate 2014-03-11 06:07:06 +00:00
Sergey Lyubka 6ffe2d7f7a Typo fixed in readme 2014-03-11 06:04:44 +00:00
Sergey Lyubka 30c82d7efe Wording in README changed 2014-03-11 06:03:20 +00:00
Sergey Lyubka 999c4ad26c 5.3 -> 5.4 2014-03-10 17:02:00 +00:00
Sergey Lyubka 30a7965135 added lsp link 2014-03-10 11:21:52 +00:00
Sergey Lyubka a8a017a048 docs updated 2014-03-10 09:23:06 +00:00
Sergey Lyubka eac8ffabc4 docs updated 2014-03-10 09:19:01 +00:00
Sergey Lyubka a7a17711ec Resetting endpoint_type in open_local_endpoint() 2014-03-10 08:35:41 +00:00
Sergey Lyubka 18e28ef879 Added lua includes 2014-03-09 20:22:51 +00:00
Sergey Lyubka ce7515fca9 Merge pull request #349 from jhorneman/master
Exposing Lua support functions
2014-03-09 20:18:49 +00:00
Jurie Horneman d5a78fb664 Fixed bug. 2014-03-09 21:12:34 +01:00
Jurie Horneman 1b3a1b74ac Exposed Lua support functions. 2014-03-09 21:11:06 +01:00
Sergey Lyubka 8dd76e6ef4 Using ns_start_thread() 2014-03-09 19:50:34 +00:00
Sergey Lyubka 976b5f37c1 Added Lua callback 2014-03-09 19:30:41 +00:00
Sergey Lyubka 31489ab7b1 Lua fixes 2014-03-09 19:26:58 +00:00
Sergey Lyubka 1eb59940a4 Re-init rewrites var in convert_uri_to_file_name() 2014-03-09 13:27:39 +00:00
Sergey Lyubka 576d769b56 Corrected links in tutorials 2014-03-09 13:13:25 +00:00
Sergey Lyubka afaba7ee17 Lua calls, birth_time fixed 2014-03-09 13:13:13 +00:00
Sergey Lyubka 40f257ef2b lua build instructions fixed 2014-03-09 13:12:49 +00:00
Sergey Lyubka 5840dc8153 Links updated 2014-03-07 17:08:23 +00:00
Sergey Lyubka 5ed3dafb56 Added warning about PHP 5.5 2014-03-07 14:46:24 +00:00
Sergey Lyubka b99bf306ec fixed image links 2014-03-07 14:40:34 +00:00
Sergey Lyubka 89fae72aa7 added 2014-03-07 14:24:37 +00:00
Sergey Lyubka ab147e8f19 Added MONGOOSE_NO_SSI to MONGOOSE_NO_FILESYSTEM 2014-03-06 13:37:23 +00:00
Sergey Lyubka 81a78f9c8b Added query string to access log 2014-03-05 11:22:23 +00:00
Sergey Lyubka 370aeefdde Added error pages and vhosts to readme 2014-03-05 11:19:18 +00:00
Sergey Lyubka c5407a75f4 #define EV_HANDLER NULL in server.c 2014-03-05 10:12:43 +00:00
Sergey Lyubka 7217aa22f1 Embedded guide 2014-03-05 02:53:19 +00:00
Sergey Lyubka 69bd5f7aa2 SSL_accept logic fix 2014-03-05 02:19:05 +00:00
Sergey Lyubka 41b3c1b23e warning squashed in convert_uri_to_file_name() 2014-03-05 01:59:58 +00:00
Sergey Lyubka f639409533 warning squashed in convert_uri_to_file_name() 2014-03-05 01:59:32 +00:00
Sergey Lyubka 67c44799c8 SSL_accept() error handling fix 2014-03-05 01:57:09 +00:00
Sergey Lyubka 4646e2ad55 Added mjpg example 2014-03-04 20:23:37 +00:00
Sergey Lyubka b77532ea3f Added mjpg example 2014-03-04 20:22:46 +00:00
Sergey Lyubka ed8168e8a1 Added virtual hosts support via url_rewrites 2014-03-04 16:15:02 +00:00
Sergey Lyubka 39e2d2ad55 Appending query_string to the URI when redirecting on HTTP error 2014-03-04 15:01:05 +00:00
Sergey Lyubka 27c6656398 SSL_accept fixes 2014-03-04 13:23:40 +00:00
Sergey Lyubka ffe83051fe build fixed 2014-03-04 13:15:56 +00:00
Sergey Lyubka 93cd77ffad Changed links 2014-03-03 21:18:57 +00:00
Sergey Lyubka 279c06c64c Cleaned up cruft from mongoose.h 2014-03-03 10:56:17 +00:00
Sergey Lyubka 570c8213b6 Cleaned unit test 2014-03-03 10:54:35 +00:00
Sergey Lyubka f521999ea6 Calling EP_CLIENT on close 2014-03-03 10:27:56 +00:00
Sergey Lyubka e41df3cf9c MG_REQ_BEGIN -> MG_REQUEST, killed MG_REQ_END, add MG_REPLY. Restored server test 2014-03-03 10:26:27 +00:00
Sergey Lyubka 65f484291f got rid of multiline comment 2014-03-03 09:45:00 +00:00
Sergey Lyubka 77db89961b mg_stat() fix for paths like X:\ 2014-03-03 01:00:38 +00:00
Sergey Lyubka ad50310bb6 Added index.shtml to index files 2014-03-02 19:49:15 +00:00
Sergey Lyubka 66ec3d1f1e Added defines for popen and pclose, for SSI under Win32 2014-03-02 18:50:02 +00:00
Sergey Lyubka a9da86d05c Mentioned SSI 2014-03-02 18:28:40 +00:00
Sergey Lyubka 5f25a88821 Restored SSI functionality 2014-03-02 18:27:51 +00:00
Sergey Lyubka fd7dc33645 unbroke unit test 2014-03-02 17:20:24 +00:00
Sergey Lyubka 9c22771a43 Merge pull request #345 from nielsegberts/master
Also clean up multi_threaded and websocket_html.c on make clean
2014-03-02 15:48:25 +00:00
Niels Egberts 11640cc3c6 Also clean up multi_threaded and websocket_html.c on make clean 2014-03-02 14:55:34 +00:00
Sergey Lyubka 2264520a2f Example changed to evented API 2014-03-02 13:05:00 +00:00
Sergey Lyubka 2f0b411ddd Added -pthread flag to unix compilation example 2014-03-02 13:00:44 +00:00
Sergey Lyubka e0aceb4f3a Fixed windows build for examples 2014-03-02 12:23:53 +00:00
Sergey Lyubka ea9a60a59a Updated examples to conform to the evented API 2014-03-02 12:16:09 +00:00
Sergey Lyubka 458320cffb Fixed #343 in conn2() for Lua 2014-03-02 10:12:12 +00:00
Sergey Lyubka e0214af422 Using private ns_avprintf() in mg_printf_data() 2014-03-02 10:07:30 +00:00
Sergey Lyubka df5e997ea7 ns_server_poll() waking up by ns_server_wakeup() 2014-03-01 01:55:40 +00:00
Sergey Lyubka 0a3cb63c73 Added mg_wakeup_server() 2014-03-01 01:47:01 +00:00
Sergey Lyubka 37f7f3fb12 Merge pull request #339 from nenioscio/master
Fix issue #338
2014-03-01 01:19:31 +00:00
Sergey Lyubka 2ac970fa16 Moving to event-based API, temporary breaking tests 2014-03-01 01:17:39 +00:00
Sergey Lyubka de35a353d4 pphp -> php 2014-02-27 22:02:18 +00:00
Klaus Wagner dbbda02f70 Fix issue #338 2014-02-27 22:12:46 +01:00
Sergey Lyubka 725c30446c more docs 2014-02-25 20:39:34 +00:00
Sergey Lyubka 60473ae41a more docs 2014-02-25 20:39:00 +00:00
Sergey Lyubka 951d20f904 Added coniditional to use net_skeleton separately 2014-02-25 18:52:23 +00:00
Sergey Lyubka 85a6abd58b Clearing flags in close_local_endpoint() 2014-02-25 12:02:45 +00:00
Sergey Lyubka 2fbe09ad7c Restored jni build dir for Android 2014-02-25 08:12:42 +00:00
Sergey Lyubka 23325efab2 Added time.h 2014-02-25 08:10:19 +00:00
Sergey Lyubka 107902bae4 add_to_set(): fix around non-negative SOCKET on Windows 2014-02-24 08:22:40 +00:00
Sergey Lyubka 9bbf4c8384 Fixed problem with mg_printf_data() 2014-02-22 16:11:47 +00:00
Sergey Lyubka c39a712540 Win32 build fix 2014-02-21 14:13:06 +00:00
Sergey Lyubka e9f6111ba1 re-added signal.h 2014-02-20 17:47:07 +00:00
Sergey Lyubka ba267a32fd squashed warning in read_from_socket 2014-02-20 17:44:47 +00:00
Sergey Lyubka f64ebbe0b1 Guarded on_cgi_data() call by ifdef, thanks to Pavel Pimenov 2014-02-20 12:33:46 +00:00
Sergey Lyubka 8865dd5e84 Moved unit_test.c to examples 2014-02-20 12:13:59 +00:00
Sergey Lyubka ce57f47de0 Added missing signal.h 2014-02-20 09:49:42 +00:00
Sergey Lyubka 48be2dbc2a Added conditional for handling idle websocket conns 2014-02-20 07:32:33 +00:00
Sergey Lyubka 8905522a94 Setting last_io_time in ns_add_sock() 2014-02-20 06:26:44 +00:00
Sergey Lyubka eea1680cf9 open_cgi_endpoint() strrchr fix 2014-02-19 16:44:01 +00:00
Sergey Lyubka d5004cb7eb PF_INET -> AF_INET, unbreaks FreeBSD 2014-02-19 16:39:30 +00:00
Sergey Lyubka 1d1a05bf39 Embedded net_skeleton 2014-02-19 16:38:53 +00:00
Sergey Lyubka 2009069037 merge 2014-02-19 16:36:27 +00:00
Sergey Lyubka 8f7703c2a9 moved to net_skeleton 2014-02-19 16:34:51 +00:00
Sergey Lyubka 8e87c4f013 Merge pull request #329 from abimaelmartell/fix/freebsd-compilation
fix compilation under FreeBSD
2014-02-14 23:46:07 +00:00
Abimael Martell 639a6dc2a8 fix compilation under FreeBSD 2014-02-14 13:21:14 -08:00
Sergey Lyubka cead9a04ca Typo fixed 2014-02-11 15:21:54 +00:00
Sergey Lyubka e528093027 Formatted example 2014-02-11 15:20:19 +00:00
Sergey Lyubka c432b783fb Formatted example 2014-02-11 15:19:18 +00:00
Sergey Lyubka e06976836f Typo fixed 2014-02-11 15:18:20 +00:00
Sergey Lyubka c9f7407573 More comments in example 2014-02-11 15:16:55 +00:00
Sergey Lyubka a40e59dbe6 URL corrected 2014-02-11 09:56:10 +00:00
Sergey Lyubka 61ee3d36d0 Merge pull request #324 from eichin/patch-1
doc typos
2014-02-11 09:55:47 +00:00
Mark Eichin 94dbf21ffb doc typos
just saw them while reading...
2014-02-11 03:41:09 -05:00
Sergey Lyubka 998425b14b Styling changes for hexdump 2014-02-10 10:21:57 +00:00
Sergey Lyubka 6900dd733a Merge pull request #322 from pavel-pimenov/master
Fix copy-paste for MONGOOSE_HEXDUMP feature
2014-02-10 09:48:26 +00:00
Pavel Pimenov 9e4cd054c8 Fix copy-paste for MONGOOSE_HEXDUMP feature 2014-02-10 12:00:51 +04:00
Sergey Lyubka 5dc317fcb0 Added -DMONGOOSE_HEXDUMP feature 2014-02-09 20:57:11 +00:00
Sergey Lyubka fbd5d77ce8 Added note about CGI env vars 2014-02-07 20:23:37 +00:00
Sergey Lyubka 6f8751b479 chat server is going to be in its own dir 2014-02-07 13:04:02 +00:00
Sergey Lyubka 877c4dc698 websocket example responses: 15 times -> 3 times 2014-02-07 13:03:28 +00:00
Sergey Lyubka 2dfc79129a better lua build 2014-02-07 13:03:11 +00:00
Sergey Lyubka 416f4bf10f Merge pull request #321 from pavel-pimenov/master
Add #ifndef MONGOOSE_NO_FILESYSTEM
2014-02-07 07:45:20 +00:00
Pavel Pimenov f9a99530ff Add #ifndef MONGOOSE_NO_FILESYSTEM 2014-02-07 11:02:12 +04:00
Sergey Lyubka 940b65e4db Merge pull request #320 from xant/upstream
added a new handler callback to be used when the http connection is being closed
2014-02-06 21:00:17 +00:00
Andrea Guzzo b22f7d3a49 added a new handler callback to be used when the http connection is being closed
so that in case of connections closed prematurely, the user can clear resources
eventually bound to the connection using the 'connection_param' member of the
mg_connection structure
2014-02-06 11:22:13 +01:00
Sergey Lyubka eaa0e26a85 Starting to rebuild chat example on Lua 2014-02-06 10:18:30 +00:00
Sergey Lyubka a3a63f7e56 Using mg_connection::callback_param for mg_iterate_over_connection() 2014-02-06 10:00:20 +00:00
Sergey Lyubka c9036f3ac0 Added workaround for non-compliant runtimes in alloc_vprintf() 2014-02-05 12:33:36 +00:00
Sergey Lyubka 60858d7fe5 NO_WEBSOCKET -> MONGOOSE_NO_WEBSOCKET 2014-02-04 19:57:00 +00:00
Sergey Lyubka 1c914bde1d Merge pull request #316 from To1ne/master
use `mg_set_request_handler`
2014-02-04 11:55:52 -08:00
Toon Claes a487332aa0 use mg_set_request_handler 2014-02-04 20:48:38 +01:00
Sergey Lyubka 3987d4d560 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-02-04 18:13:10 +00:00
Sergey Lyubka 8d3181e0bf examples/html -> examples/chat_html_root 2014-02-04 18:13:02 +00:00
Sergey Lyubka 0f1a59aeb4 Increased env buf size 4096 -> 8192. Passing TMPDIR to CGI. 2014-02-04 18:11:56 +00:00
Sergey Lyubka 2cdf259940 Merge pull request #315 from To1ne/patch-1
Correct return values: PROCESSED or CALL_AGAIN
2014-02-04 06:51:41 -08:00
Toon Claes 0187fe943a Correct return values: PROCESSED or CALL_AGAIN 2014-02-04 15:24:32 +01:00
Sergey Lyubka a34d1ec00a Better handling of MONGOOSE_NO_SOCKETPAIR 2014-02-04 14:04:54 +00:00
Sergey Lyubka e70d98b7b0 Added fixes for eCos 2014-02-04 09:59:53 +00:00
Sergey Lyubka bea012a3c1 Removed redundant addenv call 2014-02-04 08:06:49 +00:00
Sergey Lyubka eb2d470f65 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-02-03 17:54:46 +00:00
Sergey Lyubka 652c352394 Passing SERVER_NAME, TMP and TEMP env vars to CGI. 2014-02-03 17:54:31 +00:00
Sergey Lyubka f1b37b3101 Merge pull request #313 from xant/upstream
bugfix: set the correct status if we still have pending data
2014-02-03 04:52:10 -08:00
Sergey Lyubka 81b9876af8 5.2 -> 5.3 2014-02-01 16:53:09 +00:00
Sergey Lyubka 7010addadb NO_AUTH -> MONGOOSE_NO_AUTH 2014-02-01 15:17:13 +00:00
xant 9e118c8a31 bugfix: set the correct status if we still have pending data 2014-01-31 19:09:12 +01:00
Sergey Lyubka 2fc654ac35 page.lp -> dirscan.lp 2014-01-30 17:49:37 +00:00
Sergey Lyubka 45861c7890 Disabling options if functionality is not enabled 2014-01-30 14:54:02 +00:00
Sergey Lyubka 1957879e10 Casting to int in mg_sprintf() call in handle_cgi 2014-01-29 12:34:51 +00:00
Sergey Lyubka ddbe690698 CGI directory logic fixed 2014-01-29 11:42:14 +00:00
Sergey Lyubka 9ba1596c46 Closing connection after mg_send_digest_auth() 2014-01-29 01:24:21 +00:00
Sergey Lyubka de509ae952 Fix around pid_t for mingw, thanks to Jay 2014-01-28 20:09:12 +00:00
Sergey Lyubka 77817cd019 Squashed the warnings 2014-01-28 13:42:26 +00:00
Sergey Lyubka 7083bea56b mg_parse_header(): allowing no spaces for comma-separated list 2014-01-28 13:01:28 +00:00
Sergey Lyubka 3dffd7604a Removed warnings 2014-01-28 12:55:20 +00:00
Sergey Lyubka 5a67af0c73 Using 1 ms in mg_poll_server 2014-01-28 12:51:27 +00:00
Sergey Lyubka 14526a2109 mg_add_uri_handler -> mg_set_request_handler() 2014-01-28 12:42:13 +00:00
Sergey Lyubka a6cfbd2536 docs URL changed 2014-01-28 10:48:27 +00:00
Sergey Lyubka 0d28f99275 wrapped pid_t and S_ISDIR definitions into ifndef for mingw build 2014-01-27 11:12:43 +00:00
Sergey Lyubka a281e99661 calling auth handler wrapped in MONGOOSE_NO_AUTH 2014-01-27 11:10:46 +00:00
Sergey Lyubka 170df7b676 local and remote port made unsigned short 2014-01-27 11:08:32 +00:00
Sergey Lyubka 3fa5c69f98 Fixed handle_delete() stat call 2014-01-27 11:06:05 +00:00
Sergey Lyubka e31f3058fa Added test for rewrites 2014-01-27 11:03:44 +00:00
Sergey Lyubka 83a9a726d3 Checking path existence 2014-01-26 11:24:24 +00:00
Sergey Lyubka 8ae0400b0d Added ability to set "0" as listening port. Exported local_ip and local_port to the client. 2014-01-25 13:50:57 +00:00
Sergey Lyubka 037fdbcccb Ignoring chdir() return value. Resetting mg_conn in close_local_endpoint() 2014-01-25 09:45:47 +00:00
Sergey Lyubka 5d2ac4e0a6 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-01-24 20:50:21 +00:00
Sergey Lyubka f977757a9d Added mg_set_auth_handler() 2014-01-24 20:49:57 +00:00
Sergey Lyubka 1db13aeed5 Merge pull request #304 from xant/master
allow to define a default mime-type
2014-01-24 09:51:51 -08:00
Andrea Guzzo 956788d7de changed mg_get_mime_type to expect the default type as argument
instead of using a configuration option
2014-01-24 15:56:21 +01:00
Andrea Guzzo 45f6612096 allow to define a default mime-type to use when lookup in the internal table fails
instead of always returning 'text/plain'

To allow setting a different default mime-type the mg_get_mime_type() api has been
extended to require an mg_server parameter.

Note that using a static global as default mime type wouldn't have allowed us to
control it via a configuration option because there is not global initialization phase
and configuration options are provided (and specific) to each server instance.
This means that different servers can be configured to use a different default mime-type
(which is also a desired behaviour in many scenarios) when lookup fails.
2014-01-24 14:45:19 +01:00
Sergey Lyubka 2392156fd4 Not exiting on a wrong option, best effort to recover 2014-01-23 20:57:27 +00:00
Sergey Lyubka cf1811f8c3 Added build instruction for windows 2014-01-23 12:00:40 +00:00
Sergey Lyubka 93c5335d80 USE_POST_SIZE_LIMIT -> MONGOOSE_USE_POST_SIZE_LIMIT, and unit test added 2014-01-23 11:24:00 +00:00
Sergey Lyubka 192205b10b Added 2014-01-23 10:36:08 +00:00
Sergey Lyubka 0377eea9c5 Added enum for callback return codes 2014-01-22 18:25:05 +00:00
Sergey Lyubka ad89868564 Moved must_hide_file to under #ifndef MONGOOSE_NO_FILESYSTEM 2014-01-22 18:24:28 +00:00
Sergey Lyubka 976f286134 Made mg_connection::content_len int -> size_t, which is 64-bit on 64-bit systems 2014-01-20 20:57:21 +00:00
Sergey Lyubka 503a1a749d Added unit test for MONGOOSE_USE_SSL 2014-01-20 20:50:30 +00:00
Sergey Lyubka 45a4266172 more examples added 2014-01-20 11:21:35 +00:00
Sergey Lyubka 2ea17e8c6d Adjusted docs and makefile to use correct preproc flags 2014-01-20 11:17:09 +00:00
Sergey Lyubka 67b7d79710 Removed comment about MONGOOSE_USE_STACK_SIZE 2014-01-20 11:10:30 +00:00
Sergey Lyubka 2e35e25935 ENABLE_DBG -> MONGOOSE_ENABLE_DEBUG, USE_STACK_SIZE -> MONGOOSE_USE_STACK_SIZE 2014-01-20 11:04:12 +00:00
Sergey Lyubka d86d409d3c Preprocessor definitions prefixed by MONGOOSE_ 2014-01-20 10:54:15 +00:00
Sergey Lyubka 1109d3aa3c Guarded #define EINPROGRESS 2014-01-20 09:02:57 +00:00
Sergey Lyubka 8208d9e250 Fixed -DUSE_SSL build 2014-01-20 09:01:16 +00:00
Sergey Lyubka fdd086b11c moved discard_leading_iobuf_bytes() out from conditional 2014-01-20 08:55:34 +00:00
Sergey Lyubka 5825e3ea74 Adding use_ssl to mg_connect() 2014-01-20 08:55:03 +00:00
Sergey Lyubka 061ba99124 Using vnotify() for die() 2014-01-20 08:54:06 +00:00
Sergey Lyubka ead098f726 Setting server_name 2014-01-19 17:01:43 +00:00
Sergey Lyubka 7a129c17ba Added http client with unit tests 2014-01-19 16:32:43 +00:00
Sergey Lyubka 400084ea8a read_from_client -> read_from_socket 2014-01-17 16:58:19 +00:00
Sergey Lyubka 82ad9a073a Calling long running connections regardless of select() status 2014-01-17 16:37:35 +00:00
Sergey Lyubka 22aea8acac Better comment for websocket example 2014-01-17 16:37:05 +00:00
Sergey Lyubka 40e5c744da Calling long-running URI handlers on each poll iteration 2014-01-17 15:49:16 +00:00
Sergey Lyubka e648681f1d Moved mg_connect() 2014-01-17 15:42:35 +00:00
Sergey Lyubka 02f19fc05a Using mg_handler_t for iterate_over_connections() 2014-01-17 11:45:57 +00:00
Sergey Lyubka 7690f9e34b Fixed websocket example, and websocket callback calling logic. 2014-01-17 10:17:15 +00:00
Sergey Lyubka 65c1278975 win32 build of server.c fixed 2014-01-16 14:40:26 +00:00
Sergey Lyubka 05e1135940 Added stand-alone console executable 2014-01-16 13:53:18 +00:00
Sergey Lyubka 7b6e8fb93c Moved idle_timeout_ms into compile-time option 2014-01-16 13:23:23 +00:00
Sergey Lyubka 9f1679e900 Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-01-15 18:05:43 +00:00
Sergey Lyubka c0af018e20 removed build dir 2014-01-15 18:02:55 +00:00
Sergey Lyubka d553ae992a Unit test moved to top 2014-01-15 17:55:39 +00:00
Sergey Lyubka 89ef8f2f30 Removed method checks for CGI 2014-01-15 11:46:05 +00:00
Sergey Lyubka 9115a99f47 Fixed scanf format in parse_port_string() 2014-01-15 11:06:37 +00:00
Sergey Lyubka bbc65c7987 put_deleve_auth_file -> dav_auth_file. added placeholders for user 2014-01-15 07:57:59 +00:00
Sergey Lyubka bac0f75dd6 int sock -> sock_t sock 2014-01-15 07:10:09 +00:00
Sergey Lyubka 6440c358c1 C++ friendliness fix 2014-01-14 23:20:23 +00:00
Sergey Lyubka 6f84c8bbfb Using unicode API for service creation 2014-01-14 21:05:35 +00:00
Sergey Lyubka 0adbfcba96 Moved send_options out of NO_DAV conditional 2014-01-14 19:28:29 +00:00
Sergey Lyubka 136c3e8200 Eat prior POST data in close_local_endpoint() 2014-01-14 13:57:55 +00:00
Sergey Lyubka 7d699ea73c Added URI handler return value 2014-01-14 13:27:00 +00:00
Sergey Lyubka fc37b08139 URI handler status code drives streaming behavior 2014-01-14 13:16:58 +00:00
Sergey Lyubka 3aaf47d4e4 Return 1 from the URI handler 2014-01-14 12:50:13 +00:00
Sergey Lyubka 346179d1f1 keep-alive for all EP_USER requests 2014-01-14 00:44:27 +00:00
Sergey Lyubka 0148bc804a Added NO_THREADS wrapper 2014-01-13 21:35:45 +00:00
Sergey Lyubka 472e198d4a Fixed mg_parse_header to allow NULL strings 2014-01-13 21:31:18 +00:00
Sergey Lyubka bf6fc3262f Added test for static config opts 2014-01-13 21:08:03 +00:00
Sergey Lyubka 53311e8d6b removed ssi tests 2014-01-13 20:39:22 +00:00
Sergey Lyubka cc636197bc Added auth example 2014-01-13 17:58:14 +00:00
Sergey Lyubka 6b4f7e785d Added upload example 2014-01-13 17:01:11 +00:00
Sergey Lyubka 73ed83c5e3 Added mg_parse_multipart 2014-01-13 16:29:12 +00:00
Sergey Lyubka 56f128514e Implemented mg_set_http_error_handler() 2014-01-13 12:17:47 +00:00
Sergey Lyubka f0571f9fd6 Using mg.request_info.content 2014-01-13 10:58:14 +00:00
Sergey Lyubka a3663da90e Exposed mg_send_digest_auth_request(). Exported conn->content to Lua 2014-01-13 10:50:26 +00:00
Sergey Lyubka f74a1e1dc2 Fixed start_process on windows to use correct interpreter 2014-01-12 07:20:53 +00:00
Sergey Lyubka 74511b42f5 Using unicode winapi to load config file 2014-01-12 07:20:12 +00:00
Sergey Lyubka 04862eec85 Added wp target 2014-01-12 07:18:29 +00:00
Sergey Lyubka 4d105386ca Better handling of non-ascii chars for windows CGIs 2014-01-11 23:17:17 +00:00
Sergey Lyubka 44a35bb5bf Removed debug statement 2014-01-11 23:15:02 +00:00
Sergey Lyubka 022c9f0d47 Handling non-ascii chars in the binary 2014-01-11 21:32:05 +00:00
Sergey Lyubka e38061970e Exposed mg_authorize_digest() 2014-01-11 16:44:37 +00:00
Sergey Lyubka a4e8dc3069 Sending status 200 to CGI by default 2014-01-11 16:18:59 +00:00
Sergey Lyubka fa4179ee53 Made clean silent 2014-01-11 16:18:29 +00:00
Sergey Lyubka a8c8cfb665 fix non-initialized comparison 2014-01-11 10:09:26 +00:00
Sergey Lyubka e0b6109214 Added -DNO_FILESYSTEM 2014-01-11 09:48:27 +00:00
Sergey Lyubka d29f849602 Fixed optional build test 2014-01-11 09:48:13 +00:00
Sergey Lyubka 848c5d753e Fixed logic for get_url_to_me 2014-01-11 03:19:46 +00:00
Sergey Lyubka 4eef5b14fb Added comment to https://github.com/cesanta/mongoose/pull/287 2014-01-10 22:48:47 +00:00
Sergey Lyubka 283af71bbf Merge pull request #287 from oli-obk/fix/last_send_data_before_shutdown
mg_printf_data was ignored if mg_destroy_server was called directly afte...
2014-01-10 14:47:00 -08:00
Sergey Lyubka ff85b802c3 Using case-insensitive string comparison for connection: keep-alive 2014-01-10 22:46:03 +00:00
Sergey Lyubka e2b42e4117 Using case-insensitive string comparison for connection: keep-alive 2014-01-10 22:43:52 +00:00
Sergey Lyubka 63909b59c5 Added __cdecl to SSL decls to make sure correct linkage with OpenSSL which is cdecl 2014-01-10 22:41:36 +00:00
Sergey Lyubka 7380c65265 5.1 -> 5.2 2014-01-10 22:37:26 +00:00
Sergey Lyubka e9316a4feb CGI fixes 2014-01-10 21:59:37 +00:00
Oliver Schneider 2ac231cb7e mg_printf_data was ignored if mg_destroy_server was called directly after 2014-01-10 18:38:18 +01:00
Sergey Lyubka a741d53028 Fixed leak for server creation/destroy 2014-01-10 11:23:29 +00:00
Sergey Lyubka 9ea7b6f8ae Removed unnecessary buffer initializer 2014-01-10 11:11:26 +00:00
Sergey Lyubka 580d3da3c7 Using unicode winapi for stat(), fopen(), open() 2014-01-10 11:03:38 +00:00
Sergey Lyubka aa59dda966 wrapped read_from_cgi() into NO_CGI 2014-01-09 17:50:57 +00:00
Sergey Lyubka 47b92e4145 Added string defs for 301 and 302 codes in status_code_to_str() 2014-01-09 17:24:20 +00:00
Sergey Lyubka fa351959a0 5.0 -> 5.1 2014-01-09 14:08:50 +00:00
Sergey Lyubka 1414e2a236 Documented rewrites for HTTP errors 2014-01-09 12:47:29 +00:00
Sergey Lyubka 5fb275e146 Added URL rewrites for HTTP errors, to allow for error pages. 2014-01-09 12:36:25 +00:00
Sergey Lyubka 9390c66b48 Moved next_option() to the rest of string functions 2014-01-09 12:34:50 +00:00
Sergey Lyubka 2f69ca37d3 Better CGI error diagnostic for UNIX 2014-01-09 10:53:25 +00:00
Sergey Lyubka 4cd11de400 Ping only websocket connections 2014-01-09 10:37:17 +00:00
Sergey Lyubka 15a2639355 Added better diagnostic to send_http_error() 2014-01-09 10:35:43 +00:00
Sergey Lyubka c20f26dbb9 removed mg_fmt() 2014-01-09 09:58:19 +00:00
Sergey Lyubka cae797cf04 Merge branch 'master' of https://github.com/cesanta/mongoose 2014-01-09 09:37:35 +00:00
Sergey Lyubka 0d885add0e Fixed put_dir() 2014-01-09 09:36:58 +00:00
Sergey Lyubka 842231cc5c GetFullPathNameA -> GetFullPathName 2014-01-08 18:20:13 +00:00
Sergey Lyubka dc55a3ae40 Added #undef UNICODE in mongoose.c to force ANSI Win32 functions 2014-01-08 18:10:15 +00:00
Sergey Lyubka 4d85cc6c76 Removed -Wno-empty-translation-unit from unix CFLAGS :-) 2014-01-08 09:27:16 +00:00
Sergey Lyubka 8ac1b40c11 Added -Wno-empty-translation-unit to the unix CFLAGS 2014-01-08 09:19:56 +00:00
Sergey Lyubka 238b43af84 Squashed warnings for gcc 4.6.3 2014-01-08 09:16:36 +00:00
Sergey Lyubka 12c8e99bd5 Removed error_log_file from tests config 2014-01-07 14:57:08 +00:00
EC2 Default User 5f2f359bd6 Squashed warning under gcc 4.6.3 2014-01-07 14:53:48 +00:00
Sergey Lyubka ccf0ce4a1f Using chunked API in post.c example 2014-01-07 09:28:20 +00:00
Sergey Lyubka 134a5b7b9e Using chunked API in multi-threaded example 2014-01-07 09:24:48 +00:00
Sergey Lyubka d39daab29e Updated docs 2014-01-07 09:12:17 +00:00
Sergey Lyubka a798b1a937 Updated docs 2014-01-07 09:10:58 +00:00
Sergey Lyubka 04de3bb2f9 Updated docs 2014-01-07 09:05:34 +00:00
Sergey Lyubka 86da250e2c Using fat mongoose for php bundle 2014-01-06 14:58:21 +00:00
Sergey Lyubka 347a8c2f70 Fix source IP in logging 2014-01-06 14:53:41 +00:00
Sergey Lyubka 9624200663 SSL build 2014-01-06 13:31:46 +00:00
Sergey Lyubka 18b1e95350 LSP functionality 2014-01-06 13:08:39 +00:00
Sergey Lyubka 407877a4d5 added mongoose-lua.exe target 2014-01-06 12:40:41 +00:00
Sergey Lyubka 7541c6339a Removed error_log_file 2014-01-06 11:52:09 +00:00
Sergey Lyubka 31f1efd4f5 Removed index.shtml from the index files 2014-01-06 11:34:32 +00:00
Sergey Lyubka 2477f80a43 Wrapped run_as_user into conditional 2014-01-06 11:32:15 +00:00
Sergey Lyubka cf94fb3642 Added BIG_SOURCES 2014-01-06 11:29:36 +00:00
Sergey Lyubka 2210043b87 removed mutex calls. wrapped ssl_certificate option in a conditional 2014-01-06 11:22:11 +00:00
Sergey Lyubka 10872b3227 Inlined openssl definitions instead of including a header - preparing for ssl amalgamation 2014-01-05 23:52:43 +00:00
Sergey Lyubka cb324cfb9a test/page.mg.lua -> test/page.lp 2014-01-05 01:50:47 +00:00
Sergey Lyubka 4ee5849a04 Fixed spelling in readme 2014-01-05 00:01:31 +00:00
Sergey Lyubka fa216849e5 Resetting connection flags in close_local_endpoint() 2014-01-04 22:17:16 +00:00
Sergey Lyubka df6e35e330 dav_auth_file moved 2014-01-04 20:49:54 +00:00
Sergey Lyubka 96bb9aac36 Docs updated 2014-01-04 20:12:07 +00:00
Sergey Lyubka 7cec2fe280 Sorted options list 2014-01-04 20:11:55 +00:00
Sergey Lyubka 02937f8852 API doc synced 2014-01-04 14:28:20 +00:00
Sergey Lyubka 51f0cc2b67 Embed doc synced 2014-01-04 14:25:37 +00:00
Sergey Lyubka 253927008c Options doc synced 2014-01-04 14:20:47 +00:00
Sergey Lyubka 9778a4ccfc Options doc synced 2014-01-04 14:18:14 +00:00
Sergey Lyubka d0e2741832 Added new response creation interface 2014-01-04 11:31:55 +00:00
Sergey Lyubka 3a5e2fba88 5.0 lua example 2014-01-04 02:16:52 +00:00
Sergey Lyubka 85940c8045 Moved <netdb.h> to under unix includes 2014-01-04 02:05:18 +00:00
Sergey Lyubka a0b599b308 Removed protection from mg_write(). Refactored mg_iterate_over_connections() 2014-01-04 00:51:07 +00:00
Sergey Lyubka d43ccda9a7 Unbroke link to page.lp 2014-01-03 22:18:38 +00:00
Sergey Lyubka 675b83a3ef Let mongoose binary change CWD to document_root 2014-01-03 21:45:13 +00:00
Sergey Lyubka dfdfcc060d Merge branch 'master' of ssh://github.com/valenok/mongoose 2014-01-03 20:26:52 +00:00
Sergey Lyubka 143fb4f423 Fixed macos build 2014-01-03 20:26:41 +00:00
Sergey Lyubka b7eb12017c Update README.md 2014-01-03 03:29:42 +00:00
Sergey Lyubka bd1c6c1506 Update README.md 2014-01-03 03:29:09 +00:00
Sergey Lyubka efb7f4f05d Added frozen 2014-01-03 03:06:50 +00:00
Sergey Lyubka 5475fe661d Implemented USE_POST_SIZE_LIMIT 2013-12-31 13:57:51 +00:00
Sergey Lyubka 8f62822a33 Using mg_printf() 2013-12-31 13:57:19 +00:00
Sergey Lyubka 0aa1a9e324 Documented USE_POST_SIZE_LIMIT, USE_EXTRA_HTTP_HEADERS 2013-12-31 13:56:59 +00:00
Sergey Lyubka 7a77bb1c4a More descriptive comment in multithreaded example 2013-12-31 09:06:21 +00:00
Sergey Lyubka 4576b69e30 Initializing remote_ip and remote_port properly 2013-12-31 09:02:24 +00:00
Sergey Lyubka 4fd6eb597d Squashed C++ warning 2013-12-30 12:10:35 +00:00
Sergey Lyubka 257dacd7bb Squashed warning about dangerous optimization 2013-12-30 11:43:07 +00:00
Sergey Lyubka c88b7b19b3 Squashed warning on Windows, using INVALID_SOCKET 2013-12-30 11:35:33 +00:00
Sergey Lyubka 4fbfb5d0d0 Expanded hello example a little 2013-12-27 19:50:14 +00:00
Sergey Lyubka 67c678270e Minor wording changes for feeatures 2013-12-27 18:32:24 +00:00
Sergey Lyubka 049db9015b Mentioned async core 2013-12-26 12:55:50 +00:00
Sergey Lyubka 9dde225b5e Squashed C++ warning in read_from_cgi() 2013-12-26 11:45:44 +00:00
Sergey Lyubka 3a0a22f4cc Add an ability to pass listening socket to mongoose binary 2013-12-26 11:37:52 +00:00
Sergey Lyubka b4a4b15835 Removed old cruft 2013-12-26 11:33:19 +00:00
Sergey Lyubka dca2eab152 removed stdio.h 2013-12-26 10:21:09 +00:00
Sergey Lyubka f9f212442c Added comment 2013-12-26 10:20:02 +00:00
Sergey Lyubka 83793aadde Removed num_threads 2013-12-26 10:14:13 +00:00
Sergey Lyubka f7a705c40a Added multi-threaded example 2013-12-26 10:13:04 +00:00
Sergey Lyubka f5f6edcf5a Added mg_printf() back 2013-12-26 10:12:18 +00:00
Sergey Lyubka 9cb1048c66 Added lightweight feature 2013-12-26 09:33:26 +00:00
Sergey Lyubka 522a7eb554 Added socket functionality 2013-12-24 11:33:56 +00:00
Sergey Lyubka 072833acd5 Squashed win32 warnings 2013-12-23 10:01:11 +00:00
Sergey Lyubka a5aa08e408 Restored post.c in windows example build 2013-12-23 08:09:59 +00:00
Sergey Lyubka 12d98a1732 Restores post.c example 2013-12-23 08:06:35 +00:00
Sergey Lyubka a6c2c2a10b Comparing URI prefix when looking for URI handler 2013-12-23 08:06:10 +00:00
Sergey Lyubka fbe1914226 Copy -> Download and copy 2013-12-23 07:22:05 +00:00
Sergey Lyubka 64a744055f Added notes on buffering POST data and websocket data 2013-12-22 08:27:23 +00:00
Sergey Lyubka 0007e47c07 Build command re-worded 2013-12-22 08:27:02 +00:00
Sergey Lyubka 4708cce8bd mg_poll_server() returns currect time. add mg_set_listening_socket() and mg_get_listening_socket() 2013-12-21 20:52:54 +00:00
Sergey Lyubka 3eb9156e60 calling iterate_over_connections() from the IO thread 2013-12-21 20:26:55 +00:00
Sergey Lyubka 2990f9328a struct linked_list_link -> struct ll 2013-12-21 20:10:08 +00:00
Sergey Lyubka a0befd65a0 Nitpick wording 2013-12-21 16:06:00 +00:00
Sergey Lyubka 872ad8badf Added NO_* and USE_* flag descriptions 2013-12-21 16:04:22 +00:00
Sergey Lyubka 0970e080d9 Added OpenSSL support 2013-12-21 15:50:11 +00:00
Sergey Lyubka 52fe1461d5 Removed SSI 2013-12-21 14:44:29 +00:00
Sergey Lyubka d5b33adb88 Properly crafting HTTP reply line by parsing CGI reply headers 2013-12-21 10:53:20 +00:00
Sergey Lyubka ec84a148f0 Creating server ctl socket in a loop to protect from interrupt 2013-12-21 10:19:12 +00:00
Sergey Lyubka 77d5d4c921 Added sldr reference 2013-12-21 08:34:02 +00:00
Sergey Lyubka 58dab48156 Using unsigned char in deliver_websocket_frame() arithmetic 2013-12-20 17:59:07 +00:00
Sergey Lyubka 7abb406d0f put_delete_auth_file -> dav_auth_file 2013-12-20 17:57:13 +00:00
Sergey Lyubka b941dcd5c5 Removed throttle option 2013-12-20 13:34:09 +00:00
Sergey Lyubka b7adf9b52a Passing server_param to the URI callback 2013-12-20 09:44:51 +00:00
Sergey Lyubka 28f7d83a74 Commented out chat example, as it is broken atm 2013-12-19 10:46:12 +00:00
Sergey Lyubka 34ee1ef3d6 Commented out chat example, as it is broken atm 2013-12-19 10:45:41 +00:00
Sergey Lyubka e518517456 Commented out chat example, as it is broken atm 2013-12-19 10:42:39 +00:00
Sergey Lyubka 7d0662f1bc Make WEBSOCKET_PING_INTERVAL_SECONDS overridable from the command line 2013-12-18 10:13:31 +00:00
Sergey Lyubka e3751d29d5 Made mongoose send websocket PINGs automatically 2013-12-18 09:35:36 +00:00
Sergey Lyubka 04b9ccca22 Testing server PINGs 2013-12-18 09:35:19 +00:00
Sergey Lyubka 1a17165227 Sending messages every 10 seconds, to allow mongoose send PINGs 2013-12-18 09:34:36 +00:00
Sergey Lyubka b6d968f00c Added qcomm example to the build 2013-12-18 09:33:59 +00:00
Sergey Lyubka a69987a711 Updated internals manual 2013-12-16 13:45:13 +00:00
Sergey Lyubka 492328474d Only hello example left, adopted to the new API 2013-12-16 13:33:50 +00:00
Sergey Lyubka 673a2c581f Removed http client, and examples references 2013-12-16 13:32:54 +00:00
Sergey Lyubka 9ef42621e0 Fixed wrong memset() in scan_directory() 2013-12-15 10:12:19 +00:00
Sergey Lyubka f5865886b2 Respecting -run_as_user 2013-12-12 20:31:43 +00:00
Sergey Lyubka 473e2a1cb2 Added <signal.h> for linux, and squashed warning in transfer_file_data() 2013-12-12 13:51:14 +00:00
Sergey Lyubka 146cf1d1c0 Calling mg_socketpair() in a loop until success. Ignoring SIGPIPE. Squashed waring in mg_start_thread() 2013-12-12 13:43:59 +00:00
Sergey Lyubka ab73055ef3 Added side-effect note for mg_create_server() 2013-12-12 13:41:33 +00:00
Sergey Lyubka 3b83543592 Commented out irrelevant design description 2013-12-10 23:49:37 +00:00
Sergey Lyubka d4ac96c24d Some wording/spelling changes 2013-12-10 23:42:44 +00:00
Sergey Lyubka 0612129a88 Async API 2013-12-10 23:34:08 +00:00
Sergey Lyubka 9bd5903f1d API.md is split to API.md and Embed.md 2013-12-10 11:16:25 +00:00
Sergey Lyubka d4eae0e251 Added minimalistic example 2013-12-10 00:40:32 +00:00
Sergey Lyubka 4d7ea04dd8 Added cast for c++ friendliness 2013-12-10 00:19:33 +00:00
Sergey Lyubka 653fab6b41 Added skeleton lua support 2013-12-09 15:53:35 +00:00
Sergey Lyubka f4c30b746e Switched to async, non-blocking core 2013-12-09 14:18:49 +00:00
Sergey Lyubka 923e5004e8 Added CFLAGS_EXTRA to windows compilation flags 2013-12-09 11:53:55 +00:00
Sergey Lyubka b14a1e25f0 Not generating mongoose.c 2013-12-08 18:39:03 +00:00
Sergey Lyubka 5a3b1123f6 tests moved under build 2013-12-07 17:47:14 +00:00
Sergey Lyubka 6a9494b683 Added mg_get_var() to core, with unit test 2013-12-07 17:46:56 +00:00
Sergey Lyubka 63c5658a2b Fixed lua compilation under linux 2013-12-07 17:45:59 +00:00
Sergey Lyubka fe087cdce9 Fixed lsp_sock_send(), return value 2013-12-07 17:45:34 +00:00
Sergey Lyubka af7efd980c Adjusting unit test for core 2013-12-06 22:14:55 +00:00
Sergey Lyubka 2cb325c981 Added DAV to core 2013-12-06 16:01:41 +00:00
Sergey Lyubka 66435a7158 Removed speed limit feature 2013-12-06 13:02:44 +00:00
Sergey Lyubka 48417ba911 Formatting change in overview 2013-12-06 13:00:33 +00:00
Sergey Lyubka f39c4c8909 Added directory listing support to core 2013-12-06 12:55:28 +00:00
Sergey Lyubka 2a7e720f12 app code moved to qcomm.c 2013-12-06 08:53:30 +00:00
Sergey Lyubka ec22250d9b Added mg_iterate_over_connections(), mg_websocket_write() 2013-12-06 08:52:42 +00:00
Sergey Lyubka a7889756a9 Made qcomm example compile 2013-12-06 08:23:26 +00:00
Sergey Lyubka 9ac67770eb mongoose5 example 2013-12-05 23:16:12 +00:00
Sergey Lyubka 3330bca4be Using mg_handler_t 2013-12-05 16:21:53 +00:00
Sergey Lyubka 31f0409bf9 Added CGI endpoint 2013-12-05 15:03:38 +00:00
Sergey Lyubka ebf9ee089b Do not send 500 when timing out getreq() 2013-12-05 11:12:07 +00:00
Sergey Lyubka 88cf329490 Closing connection on 5xx errors 2013-12-05 10:47:03 +00:00
Sergey Lyubka bba29d32ce Using socketpair for inter-thread communication 2013-12-05 10:01:11 +00:00
Sergey Lyubka 2f1f408882 Added qc test 2013-12-05 04:14:58 +00:00
Sergey Lyubka 46a9e42b8f Async websockets work 2013-12-05 04:14:10 +00:00
Sergey Lyubka 58d3abe165 Fixed iterate_callback() 2013-12-05 00:52:42 +00:00
Sergey Lyubka 03e737829a Made URI handler work 2013-12-05 00:22:21 +00:00
Sergey Lyubka 95d8881454 Fixed spool() to properly resize, commented out non-implemented API 2013-12-04 10:19:55 +00:00
Sergey Lyubka a50a52ca91 Fixed #259 2013-12-04 10:11:12 +00:00
Sergey Lyubka 50371ef309 Introduced file_stat_t to use 64 bit file support on Windows 2013-12-03 12:08:45 +00:00
Sergey Lyubka 6192d1b53a Added send_http_error() 2013-12-03 11:12:43 +00:00
Sergey Lyubka daa9175139 Added caching support (304 response) 2013-12-03 11:01:43 +00:00
Sergey Lyubka 8a65611a8c Using core.h and modified API 2013-12-02 22:22:22 +00:00
Sergey Lyubka 6c8a0aa768 denying directory accesses 2013-12-01 10:49:25 +00:00
Sergey Lyubka 787b15551d builtin mime types defs moved to top 2013-12-01 10:28:00 +00:00
Sergey Lyubka 2c896e7e5c Added proper static file handling, but range support is still broken 2013-12-01 10:25:31 +00:00
Sergey Lyubka 0e49214c7e Added mutex protection for write calls 2013-12-01 09:46:05 +00:00
Sergey Lyubka 914606a046 fmtspool() -> mg_write() 2013-12-01 07:44:38 +00:00
Sergey Lyubka b30417e908 Made core c++ friendly 2013-12-01 00:42:04 +00:00
Sergey Lyubka 5b8d4cdf68 main(argc,argv) -> main(void) 2013-12-01 00:35:22 +00:00
Sergey Lyubka ba06d135c3 Added call_user() 2013-12-01 00:33:26 +00:00
Sergey Lyubka f0d3d7e81d Cleaning up ctl sockets 2013-11-30 23:59:53 +00:00
Sergey Lyubka d1bd15291e request pipelining done 2013-11-30 23:23:38 +00:00
Sergey Lyubka d00b7f4300 Serving files 2013-11-28 20:44:11 +00:00
Sergey Lyubka ebc909b61b Added copyright 2013-11-27 14:10:51 +00:00
Sergey Lyubka 537fb39b21 Async, non-blocking experiment 2013-11-27 14:09:34 +00:00
Sergey Lyubka e106151072 Showing port number on mongoose icon context menu 2013-11-26 22:17:29 +00:00
Sergey Lyubka 257de0709f Better wording for put_delete_auth_file option 2013-11-25 17:06:24 +00:00
Sergey Lyubka 774a819e76 Better description for put_delete_auth_file option 2013-11-25 17:05:12 +00:00
Sergey Lyubka ff1412f29d Better description for put_delete_auth_file option 2013-11-25 17:04:41 +00:00
Sergey Lyubka c6606c714f Removed symbian-specific #defines. Nokia and Symbian got killed by Microsoft. 2013-11-25 14:32:33 +00:00
Sergey Lyubka de3d4e3019 Formatted hyperlinks 2013-11-25 13:45:48 +00:00
Sergey Lyubka 2f49e63d5b Moved docstrings to API.md 2013-11-25 13:43:12 +00:00
Sergey Lyubka 988b40f70d Moved webdav functions into webdav.c 2013-11-24 17:33:05 +00:00
Sergey Lyubka b5fdd48d76 Moved websocket functions into websocket.c 2013-11-24 17:29:21 +00:00
Sergey Lyubka f4f73a8dfa Init vars in handle_cgi_request() 2013-11-23 15:04:35 +00:00
Sergey Lyubka 74711c686f Added directory scanning example, and enabled posix routines in Lua for unix environment 2013-11-23 13:58:27 +00:00
Sergey Lyubka 78c994f7cc Added /I. for CL flags 2013-11-23 13:58:01 +00:00
Sergey Lyubka 2d5d668863 Squashed warning 2013-11-23 13:48:55 +00:00
Sergey Lyubka 87279f3518 Throttling functionality removed 2013-11-23 13:47:07 +00:00
Sergey Lyubka bd10a03da0 Throttling functionality removed 2013-11-23 13:46:45 +00:00
Sergey Lyubka d138119d24 Made separate target for mongoose-lua-sqlite 2013-11-23 13:44:33 +00:00
Sergey Lyubka 73019665fa moved mg_upload() into upload.c 2013-11-23 10:49:13 +00:00
Sergey Lyubka 66824e7757 moved CGI and IO into separate files 2013-11-23 10:47:35 +00:00
Sergey Lyubka 7fe6b29218 mg_get_cookie() moved to string.c 2013-11-23 10:32:43 +00:00
Sergey Lyubka ebdf973af9 log_access() moved to log.c 2013-11-23 10:31:24 +00:00
Sergey Lyubka 71dd7a96c7 mg_url_decode() moved to string.c 2013-11-23 10:26:28 +00:00
Sergey Lyubka 886dcb3f5d get_request_len() moved to string.c 2013-11-23 10:25:20 +00:00
Sergey Lyubka 37751a2875 directory ops moved to directory.c 2013-11-23 10:24:25 +00:00
Sergey Lyubka 45347bd44c Moved mime-type functions to mime.c 2013-11-23 07:48:46 +00:00
Sergey Lyubka 8c4521af03 moved remove_double_dots_and_double_slashes() to string.c 2013-11-23 07:46:11 +00:00
Sergey Lyubka 0d2a8db626 Added #define for WSAPoll 2013-11-22 13:39:57 +00:00
Sergey Lyubka e791a795b4 typo fixed 2013-11-22 08:45:04 +00:00
Sergey Lyubka 03d846529d Update README.md 2013-11-13 03:04:31 +00:00
Sergey Lyubka 607651a3ff Squashed warning for MG_REQUEST_END 2013-11-11 17:18:48 +00:00
Sergey Lyubka 0714e0dd8f Updated Android build 2013-11-04 21:15:01 +00:00
Sergey Lyubka 224d18589f Fixed -DNO_SSL build 2013-11-02 10:24:30 +00:00
Sergey Lyubka 2fd7191836 Squashed C++ void * casting warning 2013-10-30 23:04:35 +00:00
Sergey Lyubka 853d162b55 removed double def for ssl_sw 2013-10-30 23:02:36 +00:00
Sergey Lyubka 762a68a0cf Moved some docs to markdown 2013-10-30 23:02:15 +00:00
Sergey Lyubka 1da098671e Moved docstrings to API.md 2013-10-19 14:07:46 -07:00
Sergey Lyubka f852a4db0f Moved docstrings to API.md 2013-10-19 13:14:16 -07:00
Sergey Lyubka ddea940690 Docs added 2013-10-18 08:57:59 -07:00
Sergey Lyubka 292e43b41b Removed unit test dependency 2013-10-15 13:11:47 -07:00
Sergey Lyubka 915e923e35 Firing MG_HTTP_ERROR 2013-10-10 07:46:19 -07:00
Sergey Lyubka e6ac3af454 Removed debug message 2013-10-07 17:29:53 +01:00
Sergey Lyubka 3adaf8dba9 Reaping zombies properly 2013-10-07 17:29:07 +01:00
Sergey Lyubka 1777cc6e86 Squashed warning 2013-10-07 17:28:53 +01:00
Sergey Lyubka f9f623bd60 c# example synced to the current version, and tested 2013-10-06 12:16:46 +01:00
Sergey Lyubka fe95707b4e Rewording 2013-10-06 07:24:34 +01:00
Sergey Lyubka a631ee1e1e Service code refactored 2013-10-05 07:45:05 +01:00
Sergey Lyubka 493666dac6 Wording and links corrected 2013-10-03 19:34:27 +01:00
Sergey Lyubka 46ef4e33c8 Wording and links corrected 2013-10-03 19:34:00 +01:00
Sergey Lyubka cafaecfc56 Moved HTTP client, ssl and some util code into separate files 2013-10-03 19:09:35 +01:00
Sergey Lyubka 47606a71ee Moved unix and win32 code to different files 2013-10-02 23:21:13 +01:00
Sergey Lyubka eedfedd13b Added reference to a relevant pull request in getreq() comment 2013-10-01 19:09:29 +01:00
Sergey Lyubka 87d841d81b Set content_len to 0 for GET requests without Content-Length header. 2013-10-01 18:49:44 +01:00
Sergey Lyubka 5153eebc9b mg_read() does not block on content_len=0. mg_read() reads until socket is closed if content-length is not provided 2013-10-01 17:47:32 +01:00
Sergey Lyubka 70154f6c23 Moved mod_lua.c to src/lua.c 2013-10-01 15:16:09 +01:00
Sergey Lyubka d3577b7877 Moved auth code to separate file 2013-10-01 14:54:26 +01:00
Sergey Lyubka 199e0a330f Moved options handling to src/options.c 2013-09-30 19:57:33 +01:00
Sergey Lyubka a8da1b3334 Moved date parsing in build/src/parse_date.c 2013-09-30 19:51:16 +01:00
Sergey Lyubka 63c19b4631 Moved to unix file format 2013-09-30 13:11:24 +01:00
Sergey Lyubka 1f471e1cf3 Moved string functions to src/string.c 2013-09-30 13:09:16 +01:00
Sergey Lyubka ef28c37529 Removed mg_get_request_info() 2013-09-30 13:02:36 +01:00
Sergey Lyubka cd7e1b9eb7 Moved more ssl defs to internal.h 2013-09-30 12:59:43 +01:00
Sergey Lyubka 226d476856 Moved more defines to internal.h. Squashed some warnings in win32 2013-09-29 23:58:32 +01:00
Sergey Lyubka 21965e0e03 Splitting monolithic mongoose.c to separate files. Amalgamating into mongoose.c for release. 2013-09-29 23:56:59 +01:00
Sergey Lyubka 40ab4a8d3d Fixed websocket example logic when freeing the message, again! 2013-09-29 22:43:58 +01:00
Sergey Lyubka e84d0574fa Fixed websocket example logic when freeing the message 2013-09-29 22:01:31 +01:00
Sergey Lyubka 1a64d37fc7 Fixed mg_websocket_read() 2013-09-29 09:25:47 +01:00
Sergey Lyubka 9cca843a9b Typo fixed 2013-09-29 08:01:14 +01:00
Sergey Lyubka ecbf79135f Refactored API, returned back to event-based handlers. Upload and Websocket API simplified 2013-09-28 11:00:54 +01:00
Sergey Lyubka 96eb48902b Always invoking test 2013-09-28 00:15:24 +01:00
Sergey Lyubka 079c99c47f Started to restore single callback function 2013-09-26 13:25:51 +01:00
Sergey Lyubka 6d2a76b609 Added c# example 2013-09-26 12:50:11 +01:00
Sergey Lyubka 24e0950ca2 Using stdcall for mongoose.dll 2013-09-26 12:49:41 +01:00
Sergey Lyubka 98214ce1a4 Removed init_lua() and open_file() callbacks 2013-09-26 09:35:07 +01:00
Sergey Lyubka 7eed7eab36 Added mongoose.dll target 2013-09-26 09:34:36 +01:00
Sergey Lyubka f0fb5c01a2 Added unit_test.c dependency for unix_unit_test 2013-09-25 22:58:36 +01:00
Sergey Lyubka a92aa3bf49 Added unix_unit_test as a dependancy for mongoose 2013-09-25 18:37:17 +01:00
Sergey Lyubka b12cc9fd49 Refactored handle_options_request() to use mg_write() with less copying 2013-09-25 18:30:51 +01:00
Sergey Lyubka a61c3a2636 Added handle_delete_request(). Refactored convert_uri_to_file_name() 2013-09-25 18:24:36 +01:00
Sergey Lyubka 9fd435059f Setting user_data for fake connection 2013-09-25 14:28:09 +01:00
Sergey Lyubka 3156ac9791 read_websocket(): check for WEBSOCKET_OPCODE_CLOSE corrected 2013-09-25 14:25:14 +01:00
Sergey Lyubka b946f33189 Moved more docs to the web site 2013-09-24 11:24:10 +01:00
Sergey Lyubka 1e0b7054e6 Added mongoose.h to the mongoose.c dependancy 2013-09-24 11:23:51 +01:00
Sergey Lyubka 46e04e857c Added test for dir with non-ascii char 2013-09-24 10:08:39 +01:00
Sergey Lyubka 4abdeaddbf Docs reference moved to downloads section 2013-09-20 13:30:20 +01:00
Sergey Lyubka 029af1c376 Docs moved to Cesanta site 2013-09-20 13:27:48 +01:00
Sergey Lyubka c02f2ff4bb Update instruction to clone Git repo rather then using tarball 2013-09-18 09:52:06 +01:00
Sergey Lyubka f74fec8a7e Split docs by sections 2013-09-18 09:44:12 +01:00
Sergey Lyubka 50f8e8891b Removed references to usermanual.md 2013-09-18 09:44:00 +01:00
Sergey Lyubka d67b1dbd53 Added CommonProgramFiles(x86) to the CGI environment under Win32, to make Win32::OLE work under CGI 2013-09-18 08:11:37 +01:00
Sergey Lyubka b0eeb7d67b Renamed retina icons to @2x.png 2013-09-18 08:07:44 +01:00
Sergey Lyubka 2c6c75cbad Added icns icon file 2013-09-18 08:07:24 +01:00
Sergey Lyubka 241388b8a0 Using icns as bundle icon file 2013-09-18 08:07:06 +01:00
Sergey Lyubka 820b497f42 Installing icns file in DMG 2013-09-18 08:06:48 +01:00
Sergey Lyubka 88d8435a02 mongoose_22x22.png -> mongoose_22x22, let OS get Retina icon automatically 2013-09-18 08:06:08 +01:00
Sergey Lyubka f3f177f3ed Removed analytics tracking 2013-09-17 16:47:27 +01:00
Sergey Lyubka bfa171cd97 Squashed warning: added #include <direct.h> for windows getcwd() 2013-09-17 16:14:50 +01:00
Sergey Lyubka 19c94ce218 Fix for the issue 109 2013-09-17 16:09:00 +01:00
Sergey Lyubka 5e5033a0f3 Fix for the issue 156 2013-09-16 23:25:30 +01:00
Sergey Lyubka 411a269991 valenok -> cesanta 2013-09-16 22:45:19 +01:00
Sergey Lyubka bca6aab5a5 Moved UserManual to docs/ 2013-09-16 22:42:29 +01:00
Sergey Lyubka 330e2ff74e Fixed macos build target 2013-09-16 22:42:18 +01:00
Sergey Lyubka eb5848478c Added credits section mentioning those great who contributed 2013-09-12 17:30:03 +01:00
Sergey Lyubka 5bb361b1d2 Squashed warnings 2013-09-12 10:03:04 +01:00
Sergey Lyubka 0d40364089 Removed unused stuff, lua & ssl sources, reorganized targets. 2013-09-12 10:02:50 +01:00
Sergey Lyubka 16c4fe1f37 4.1 -> 4.2 2013-09-07 22:05:39 +01:00
Sergey Lyubka 3070e8572d removed file locking on windows, to fix the crash introduced by 52e3be5c58 2013-09-07 22:04:59 +01:00
Sergey Lyubka baf4d8af27 Mongoose_$V.dmg -> Mongoose-$V.dmg 2013-09-07 22:04:09 +01:00
Sergey Lyubka d5acf2e2a7 4.0 -> 4.1 2013-09-07 20:21:27 +01:00
Sergey Lyubka 22f8cb14d5 Updated downloads link 2013-09-07 20:20:11 +01:00
Sergey Lyubka e28b3ca91d Not ignoring SIGCHLD, cause it renders system() unusable on QNX 2013-09-07 19:50:54 +01:00
Sergey Lyubka 73d2b395d1 Moved SIGCHLD handler out of mongoose.c. Embedded user must set SIGCHLD handler if CGI is used. 2013-09-07 19:41:40 +01:00
Sergey Lyubka e556a487e0 Fix for the SCRIPT_NAME in the presence of PATH_INFO, https://code.google.com/p/mongoose/issues/detail?id=403 2013-09-07 18:49:24 +01:00
Sergey Lyubka 5728fa1cea Added windows_tiny target. Adding only mongoose.[ch] files to the source tarball. 2013-09-07 18:47:38 +01:00
Sergey Lyubka b461edabd9 Squashed warnings 2013-09-07 18:46:50 +01:00
Sergey Lyubka c9e666babc Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-09-07 07:07:28 +01:00
Sergey Lyubka 18e64397fc Fixed tests 2013-09-07 07:07:18 +01:00
Sergey Lyubka 3c8418d324 Removed -I$(LUA) from LUA_FLAGS 2013-09-07 07:07:07 +01:00
Sergey Lyubka 784a1580ce Merge pull request #232 from ellusak/master
use chunked encoding for directory listing
2013-09-05 11:18:07 -07:00
Sergey Lyubka 6a0ac69761 version 3.9 -> 4.0 2013-09-05 12:35:44 +01:00
ellusak 7c06279a8c use chunked encoding for directory listing 2013-09-05 17:14:34 +08:00
Sergey Lyubka aec6f85f55 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-09-02 11:15:57 +01:00
Sergey Lyubka 52e3be5c58 Refactored f[un]lockfile for Windows using LockFileEx/UnlockFileEx 2013-09-02 11:15:48 +01:00
Sergey Lyubka 01a664ad06 Merge pull request #231 from tehnick/fix-compilation-warning
Fixed compilation warning
2013-08-31 03:08:06 -07:00
Boris Pek 94933047a7 Fixed compilation warning 2013-08-30 21:32:58 +03:00
Sergey Lyubka cd6005c86f Calling thread_stop() before free-ing conn 2013-08-28 09:54:00 +01:00
Sergey Lyubka 6d14ed3a18 thread_setup -> thread_start 2013-08-28 09:53:10 +01:00
Sergey Lyubka 0fb5db59d3 Putting CFLAGS at the end of the compilation flags for Linux 2013-08-27 00:02:40 +01:00
Sergey Lyubka 20b274bb2b Using amalgamated lua 2013-08-27 00:01:53 +01:00
Sergey Lyubka 00b289a0f4 Added thread_start() and thread_stop() 2013-08-26 12:22:38 +01:00
Sergey Lyubka 9818f9849b Added downloads section 2013-08-20 16:26:33 +01:00
Sergey Lyubka df1c23222e Corrected google group email address. Reworded paragraph about SLRE. 2013-08-20 07:54:28 +01:00
Sergey Lyubka f18ac3e094 Fixed test invokation 2013-08-19 19:10:41 +01:00
Sergey Lyubka d8596fae27 Fixed unit test 2013-08-19 19:10:17 +01:00
Sergey Lyubka 85209ac4fa Reverted contributions by jmucchiello 2013-08-19 11:54:47 +01:00
Sergey Lyubka a58e82b301 Added note about GNU make 2013-08-19 11:39:59 +01:00
Sergey Lyubka 35f485558b Amalgamated Lua 2013-08-19 07:56:13 +01:00
Sergey Lyubka 93365fcbd2 audio/ogg -> application/ogg 2013-08-19 06:46:13 +01:00
Sergey Lyubka e40a44ba70 Moved mod_lua to build/ 2013-08-18 23:04:36 +01:00
Sergey Lyubka 1eed770238 Moved Makefile and main.c to build/ 2013-08-18 23:02:43 +01:00
Sergey Lyubka 511ef4137f Better SSI mime type handling 2013-08-18 13:27:54 +01:00
Sergey Lyubka 479164129b Styling, lines > 80 chars 2013-08-18 13:16:53 +01:00
Sergey Lyubka 08746115e2 Sending EXTRA_HTTP_HEADERS in handle_file_request() 2013-08-18 13:03:39 +01:00
Sergey Lyubka 587aad75c1 License change 2013-08-16 11:28:50 +01:00
Sergey Lyubka 218428662e License change 2013-08-16 11:18:16 +01:00
Sergey Lyubka 04fc209644 removing dmg dir on clean 2013-08-16 11:18:04 +01:00
Sergey Lyubka 53bedd1eb5 made separate targets for each example 2013-08-16 11:17:15 +01:00
Sergey Lyubka a0b43ae8e0 Merge pull request #218 from MikieMorales/patch-3
Changing Embedding example to C file.
2013-08-14 09:50:07 -07:00
Miguel Morales 866a7e2823 Changing Embedding example to C file. 2013-08-14 12:38:32 -04:00
Sergey Lyubka 2055d41a9f Corrected misplaced brackets in parse_http_message() 2013-08-14 10:55:36 +01:00
Sergey Lyubka 1ef29c1b3b Using #define MGSQLEN for the socket queue length 2013-08-14 08:23:30 +01:00
Sergey Lyubka e95dbb90a7 Sending content-length from put_file() 2013-08-14 08:15:42 +01:00
Sergey Lyubka cf18c932a4 Refactored parse_http_message() 2013-08-14 07:41:47 +01:00
Sergey Lyubka a730afc44d Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-08-14 07:09:28 +01:00
Sergey Lyubka 94296c9697 Corrected check for websocket connection close 2013-08-14 07:09:22 +01:00
Sergey Lyubka 667707df50 Merge pull request #214 from DanielOaks/server_software
Added SERVER_SOFTWARE CGI variable
2013-08-13 04:28:26 -07:00
Daniel Oaks 90b6fab3bb Added SERVER_SOFTWARE CGI variable 2013-08-13 21:21:05 +10:00
Sergey Lyubka e47dbcbdc5 Merge pull request #213 from MikieMorales/patch-1
Update UserManual.md
2013-08-12 08:59:39 -07:00
MikieMorales 2a15f8d567 Update UserManual.md
SheBang wikipedia link is broken due to the end parenthesis. I tried escaping it with backslash and it seems to be working now.
2013-08-12 11:23:11 -04:00
Sergey Lyubka b5d397c74f Merge pull request #212 from pas2k/master
Consume \n in mg_fgets when reading from membuf
2013-08-12 04:16:19 -07:00
Pavel Khlebovich 3d6b373c8f (mg_fgets) Accept lines at the end not terminated by \n
(mg_fgets) Don't consume more than size bytes when line cannot fit into buffer.
2013-08-12 14:27:20 +04:00
Sergey Lyubka ed236dddeb changed signature for mg_exec_lua_script(). fixed lua_error_handler() 2013-08-12 09:53:42 +01:00
Sergey Lyubka 596fb1e88a Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-08-12 09:52:22 +01:00
Sergey Lyubka ca0cd5040d Updated sqlite 2013-08-12 09:52:10 +01:00
Pavel Khlebovich 5b84acbc14 Consume \n in mg_fgets when reading from membuf. 2013-08-12 00:47:12 +04:00
Sergey Lyubka c12838e2c3 Merge pull request #211 from nigels-com/msc_ver
gcc complains about _MSC_VER being an undefined macro.
2013-08-08 22:50:19 -07:00
Nigel Stewart fa3e6ce271 gcc complains about _MSC_VER being an undefined macro. 2013-08-08 22:08:00 -05:00
Sergey Lyubka 743f48b8e0 Added mg_exec_lua_script, mg_prepare_lua_environment -> prepare_lua_environment 2013-08-08 13:11:05 +01:00
Sergey Lyubka 421c16b2bb Added -DLUA_USE_DLOPEN, and added mongoose.o: mod_lua.c 2013-08-08 12:15:40 +01:00
Sergey Lyubka 3054a7f09e Make sure child closes all pipe fds when executing CGI 2013-08-03 07:18:25 +01:00
Sergey Lyubka 2de96bd54e Workaround for non-compliant vsnprintf() 2013-08-02 11:00:21 +01:00
Sergey Lyubka f815c315e7 Added git analytics link 2013-08-01 14:20:35 +01:00
Sergey Lyubka e59ee00154 Added request_timeout_ms 2013-07-30 15:21:34 +01:00
Sergey Lyubka b07745ab50 Added Lua dll example 2013-07-30 14:49:52 +01:00
Sergey Lyubka 2468a8fb38 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-07-30 11:19:42 +01:00
Sergey Lyubka ed38a4102e showing error string as well as numeric error on bind failure 2013-07-30 11:19:33 +01:00
Sergey Lyubka b1c66f6544 Merge pull request #207 from bick4ord/master
Add casts to fix strict compiler errors [-fpermissive]
2013-07-29 13:20:43 -07:00
bick 8f79a0564f Add casts to fix strict compiler errors [-fpermissive]
When using g++ and enforcing strict compiler errors, this commit fixes the following:

mongoose.c: In function ‘char* mg_fgets(char*, size_t, file*, char**)’:
mongoose.c:2405:60: error: invalid conversion from ‘void*’ to ‘char*’ [-fpermissive]

mongoose.c: In function ‘int set_ports_option(mg_context*)’:
mongoose.c:4586:64: error: invalid conversion from ‘void*’ to ‘socket*’ [-fpermissive]

mongoose.c: In function ‘void* worker_thread(void*)’:
mongoose.c:5104:28: error: invalid conversion from ‘void*’ to ‘mg_context*’ [-fpermissive]

mongoose.c: In function ‘void* master_thread(void*)’:
mongoose.c:5220:28: error: invalid conversion from ‘void*’ to ‘mg_context*’ [-fpermissive]
mongoose.c:5235:58: error: invalid conversion from ‘void*’ to ‘pollfd*’ [-fpermissive]
2013-07-29 11:46:24 -07:00
Sergey Lyubka 2e93cde929 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-07-28 12:15:30 +01:00
Sergey Lyubka e53d05637a Binding to IPv6 addresses 2013-07-28 12:15:16 +01:00
Sergey Lyubka 9d75d35365 v. x.x -> v.x.x 2013-07-28 08:20:21 +01:00
Sergey Lyubka 2ea8d85cff Merge pull request #206 from bick4ord/master
adding include of openssl/err.h to fix errors when NO_SSL_DL is defined:
2013-07-26 22:48:49 -07:00
bick ea81a22529 adding include of openssl/err.h to fix errors when NO_SSL_DL is defined:
mongoose.c:4680:23: error: ‘ERR_get_error’ was not declared in this scope
mongoose.c:4681:52: error: ‘ERR_error_string’ was not declared in this scope
2013-07-26 14:12:33 -07:00
Sergey Lyubka 526f3aa31c Added check for document_root != NULL in convert_uri_to_file_name(). Added #define rmdir _rmdir for win32 2013-07-25 07:22:02 +01:00
Sergey Lyubka 62d66201c9 make match_prefix() case-insensitive 2013-07-25 07:07:25 +01:00
Sergey Lyubka f32e14478f Merge pull request #203 from JoseGoncalves/fixes
Fix uninitialized argument in getsockname().
2013-07-24 04:58:27 -07:00
José Miguel Gonçalves ca019799b9 Fix uninitialized argument in getsockname(). 2013-07-24 12:24:13 +01:00
Sergey Lyubka c6fb9ac3d0 Fixed indenting in is_put_or_delete_request() 2013-07-23 08:24:52 +01:00
Sergey Lyubka c80a88a407 Added test for uploading 2 files 2013-07-23 08:17:00 +01:00
Sergey Lyubka f2e19ca3ff Fixed indenting 2013-07-23 08:16:38 +01:00
Sergey Lyubka 16c463d2e9 Added compile-time option to set stack size 2013-07-22 10:10:19 +01:00
Sergey Lyubka 6a99518048 updated readme 2013-07-22 09:54:02 +01:00
Sergey Lyubka 3b242ec68b Added Android makefile 2013-07-22 09:45:23 +01:00
Sergey Lyubka 7409166409 Updated readme 2013-07-22 09:30:01 +01:00
Sergey Lyubka ca66b84f7d Updated readme 2013-07-22 09:27:47 +01:00
Sergey Lyubka dc1c732f11 Updated readme 2013-07-22 09:24:17 +01:00
Sergey Lyubka 61148f1323 Using absolute paths for all file/directory options 2013-07-22 08:23:15 +01:00
Sergey Lyubka 136e3e353d updated readme 2013-07-21 10:09:47 +01:00
Sergey Lyubka c70b80e4e1 marketing for LSP added 2013-07-20 15:30:00 +01:00
Sergey Lyubka cba4c9d85d removed travis icon 2013-07-20 15:26:05 +01:00
Sergey Lyubka 3e588065dc removed 2013-07-20 15:25:39 +01:00
Sergey Lyubka 35cb27dbe6 Always use absolute path for document_root. If relative path is used, it is relative to mongoose.exe directory. See https://github.com/valenok/mongoose/issues/181 2013-07-20 14:11:05 +01:00
Sergey Lyubka d6b9f76e9c Added COPT to CFLAGS 2013-07-20 14:08:06 +01:00
Sergey Lyubka a9d51c0e87 squashed warning 2013-07-20 11:33:34 +01:00
Sergey Lyubka 4b163232e3 fixed docstring for mg_get_valid_option_names 2013-07-20 07:12:49 +01:00
Sergey Lyubka e003236a03 Made SSI #include file= relative to the current doc, as per spec 2013-07-19 07:57:47 +01:00
Sergey Lyubka de7745370c Merge pull request #200 from ejohnstown/master
Allow no SSL_CERTIFICATE when using init_ssl callback.
2013-07-18 23:35:16 -07:00
Sergey Lyubka 21786eec8e Changed int -> SOCKET where appropriate, per Ben Currie 2013-07-18 18:17:48 +01:00
Sergey Lyubka 036b213b2b Added connection-specific conn_data pointer to struct mg_request_info 2013-07-18 17:31:16 +01:00
John Safranek 61f5f0b725 Allow no SSL_CERTIFICATE when using init_ssl callback. 2013-07-17 16:37:28 -07:00
Sergey Lyubka d864d72470 On windows, enclosing path to CGI script in quotes to allow paths with spaces 2013-07-17 08:24:52 +01:00
Sergey Lyubka 7ca5962d2d in pull_all() and read_request(), respect ctx->stop_flag() 2013-07-16 17:17:36 +01:00
Sergey Lyubka 8ce1562f0d Using SetHandleInformation() to make socket handles on Windows non-inheritable 2013-07-16 15:52:40 +01:00
Sergey Lyubka 49d9016275 For lua, let mg.read() read only if the data is there. 2013-07-16 13:56:00 +01:00
Sergey Lyubka cdc7380d00 3.8 -> 3.9 2013-07-16 08:13:00 +01:00
Sergey Lyubka e645b33b6c using mg.read() only for POST requests 2013-07-16 07:53:08 +01:00
Sergey Lyubka 30f71a8bc4 Added description for the connect() socket interface 2013-07-16 07:24:39 +01:00
Sergey Lyubka faa030385c Removing extra SSL_shutdown() call. 2013-07-15 18:20:16 +01:00
Sergey Lyubka feb3b5db96 Using $(FLAGS) for cocoa target 2013-07-15 10:52:27 +01:00
Sergey Lyubka 508b67d6f5 Removed /Gd from windows compilation flags, cause that breaks sqlite3 + fts (qsort callback is __cdecl, not __stdcall) 2013-07-15 10:41:47 +01:00
Sergey Lyubka 133aec777d Added enable_keep_alive description 2013-07-15 10:32:52 +01:00
Sergey Lyubka 389ed4e099 Enabling FTS in sqlite 2013-07-15 10:28:52 +01:00
Sergey Lyubka bc40aa5442 fixed strtoll() for win32: using _atoi64 2013-07-14 12:49:24 +01:00
Sergey Lyubka 5fb9aca2e1 Added -mmacosx-version-min for macos build 2013-07-12 12:39:19 +01:00
Sergey Lyubka c68df310b8 Added mg_websocket_write(), per morgan3d pull request 2013-07-12 12:25:25 +01:00
Sergey Lyubka 70ce6c5ad3 Added comments to read_websocket(), per morgan3d pull request 2013-07-12 11:55:52 +01:00
Sergey Lyubka 460738f11b Corrected link to Android NDK 2013-07-11 14:41:04 +01:00
Sergey Lyubka a09ec8988e Added lua.lib target 2013-07-11 14:24:24 +01:00
Sergey Lyubka c46aa050ae MAX_OPTIONS 40 -> 100 2013-07-11 11:37:39 +01:00
Sergey Lyubka 348db16245 NOT redirecting stderr to stdout for UNIX CGI, to avoid output being littered with error messages. 2013-07-11 08:44:51 +01:00
Sergey Lyubka c0ca6a53be put_delete_auth_file is the correct option name 2013-07-10 19:08:21 +01:00
Sergey Lyubka e58d622d5f Added note about /Gz for OpenSSL & Windows 2013-07-10 07:57:20 +01:00
Sergey Lyubka bcb294620f increased buffer for the ip address string from 20 to 50, to allow ipv6 addresses 2013-07-10 07:48:06 +01:00
Sergey Lyubka 15937a9c5c readme updated 2013-07-10 07:37:56 +01:00
Sergey Lyubka fa160cb9a3 Merge pull request #191 from kblinova/master
Detect Window's style slashes in mg_upload file names
2013-07-01 00:47:21 -07:00
Sergey Lyubka 137d6484e2 Removed bogus comment 2013-07-01 08:46:20 +01:00
Sergey Lyubka e7c34c26cb mg_read() with no Content-Length would read until socket is closed 2013-07-01 08:45:07 +01:00
Katerina Blinova dfb7d928c2 Review revision for windows path separator detection in mg_upload 2013-06-28 11:05:33 -07:00
Katerina Blinova 4bb9faaf50 Detect Window's style slashes in mg_upload file names 2013-06-27 11:46:52 -07:00
Sergey Lyubka a856971b6d Update README.md 2013-06-27 13:07:34 +01:00
Sergey Lyubka 4a88ad5ca9 Merge pull request #184 from unrzn0/master
MKCOL and DELETE
2013-06-11 15:30:39 -07:00
Stefan Doehla 17ecb0a459 MKCOL and recursive DELETE 2013-06-12 00:04:07 +02:00
Sergey Lyubka afd39abc6f Update README.md 2013-06-06 05:28:46 +02:00
Sergey Lyubka 4babcff8de Update UserManual.md 2013-06-03 08:18:41 +02:00
Sergey Lyubka 17d48b1d04 Update README.md 2013-06-01 12:23:16 +02:00
Sergey Lyubka 6ab20ed9a3 Update README.md 2013-06-01 12:21:02 +02:00
Sergey Lyubka a0e5494569 Merge pull request #177 from arvidn/master
support serving pre-gzipped files
2013-05-30 10:14:45 -07:00
Sergey Lyubka f62c733990 Merge pull request #176 from codyhanson/portRangeFix
Added bounds checking for listening_ports.
2013-05-30 10:05:21 -07:00
arvidn d283e3167f support serving pre-gzipped files transparently provided the user agent accepts gzip content-encoding. The feature breaks if the user agent makes a range request within a gzipped file, and returns 501 in this case 2013-05-30 09:59:11 -07:00
Cody Hanson 94050d44e4 Added bounds checking for listening_ports.
Needs to be a valid TCP port number, and not less than 1 or greater than 65535
2013-05-30 10:54:59 -06:00
Sergey Lyubka dee97cbf22 Update README.md 2013-05-30 18:24:41 +02:00
Sergey Lyubka be01471968 Update README.md 2013-05-29 13:40:57 +02:00
Sergey Lyubka a74c44c463 Update README.md 2013-05-29 13:37:31 +02:00
Sergey Lyubka 81e53d8375 Update README.md 2013-05-26 19:12:12 +02:00
Sergey Lyubka ca626abcac Update README.md 2013-05-23 18:50:49 +02:00
Sergey Lyubka b5e7730ac7 Update README.md 2013-05-22 23:56:07 +02:00
Sergey Lyubka 33b920ed2c Exported mg_url_encode() 2013-05-19 08:00:42 +01:00
Sergey Lyubka b5b234fab2 Improved docstring for mg_read() 2013-05-19 08:00:12 +01:00
Sergey Lyubka af89d2446b Squashed warnings on win32 in Lua code 2013-05-19 07:46:15 +01:00
Sergey Lyubka 791ad49651 Merge pull request #172 from jwang11/master
Securely close SSL connection by standard SSL_shutdown
2013-05-18 23:43:51 -07:00
jwang 063b26fece Securely close SSL conection
For SSL in close_connection, current implementation use close_socket_gracefully to close socket firstly, then SSL_free. In my
testing, this approach may cause some pending write data missing. I'd suggest use standard SSL_shutdown in SSL conection. It
need call twice according to openSSL manual - one call sends the close_notify alert and one call receives the response from
the peer
2013-05-19 10:40:10 +08:00
Sergey Lyubka add079a949 Added socket functions to lua environment 2013-05-19 01:25:54 +01:00
Sergey Lyubka 6e59ad8a0d Fix for prepare_lua_environment 2013-05-19 01:25:10 +01:00
Sergey Lyubka f4862b646d defined ALL_WINOBJS and using it for windows build 2013-05-18 15:21:52 +01:00
Sergey Lyubka 91fa767efb Fix doc string for websocket_data() 2013-05-18 15:21:20 +01:00
Sergey Lyubka 5e78711467 Fixed masking in websocket code 2013-05-18 10:29:03 +01:00
Sergey Lyubka b4a622cfd6 merge 2013-05-17 11:00:36 +01:00
Sergey Lyubka 8c118bf4cc Exported mg_prepare_lua_environment() 2013-05-17 10:52:40 +01:00
Sergey Lyubka 728ebdaafa Merge pull request #170 from oerik/movadd
Added .mov (quicktime) to builtin_mimes_types
2013-05-16 05:39:10 -07:00
Erik Oomen 3a186976d7 Added .mov (quicktime) to builtin_mimes_types 2013-05-16 14:33:58 +02:00
Sergey Lyubka 2e232b3304 Lua functionality change: print renamed to mg.write, read renamed to mg.read. Expanded user manual, fixed example pages. 2013-05-15 17:42:34 +01:00
Sergey Lyubka d72645bf91 Using local var in open_auth_file 2013-05-15 09:43:38 +01:00
Sergey Lyubka 7d5bcec92d Better cleanup in close_connection() 2013-05-15 08:28:56 +01:00
Sergey Lyubka 215ea28db0 Added lua to the repo 2013-05-14 13:41:44 +01:00
Sergey Lyubka 9b76d60b38 Merge pull request #131 from abadc0de/lua_read_fixup
lsp_mg_read: remove dead code, return nil on empty read
2013-05-13 10:15:34 -07:00
Sergey Lyubka 63ccf8199f Style changes in poll() 2013-05-13 18:07:38 +01:00
Sergey Lyubka 6bc6022aa9 Merge pull request #164 from fredfung/master
Fix parameter 1 for select in poll()
2013-05-13 10:05:26 -07:00
ff.feng b68db66e97 Fix parameter 1 for select in poll() 2013-05-13 23:57:26 +08:00
Sergey Lyubka 94e1c5a41b Added sanity checking in send_file_data() 2013-05-12 23:17:44 +01:00
Sergey Lyubka ab16220861 Not leaking socket in set ports option 2013-05-10 15:40:19 +01:00
Sergey Lyubka c0eb3e56b4 Not using realloc2 in set_ports_option 2013-05-10 15:21:55 +01:00
Sergey Lyubka 5591aa5a0d Added .ttf mime type, https://github.com/valenok/mongoose/issues/129 2013-05-10 14:45:12 +01:00
Sergey Lyubka 6f946f5eea websocket code fix, https://github.com/valenok/mongoose/pull/146 2013-05-10 13:41:48 +01:00
Sergey Lyubka 39cd5b8323 Signature for mg_get_cookie changed 2013-05-10 13:14:04 +01:00
Sergey Lyubka ca96db714a Updated readme 2013-05-10 12:30:30 +01:00
Sergey Lyubka a7f97bf2f2 Fixed leaks, per afs-bb https://github.com/valenok/mongoose/pull/161 2013-05-10 12:22:04 +01:00
Sergey Lyubka e579355b01 url_decode -> mg_url_decode 2013-05-08 11:40:13 +01:00
Sergey Lyubka cfbaf7f1ae Expose mg_url_decode to the API 2013-05-08 11:36:38 +01:00
Sergey Lyubka ce26234ace Merge pull request #159 from aerotech/master
_CRT_SECURE_NO_WARNINGS should not generate a warning if already defined
2013-05-07 03:29:03 -07:00
Pavel c28dc45d4c removing warning about _CRT_SECURE_NO_WARNINGS if it is already defined
modified:   mongoose.c
2013-05-06 09:02:30 -04:00
Sergey Lyubka 98b6c5e16a Merge pull request #157 from Thileepan/master
Environment variable required for PHP cgi
2013-05-06 01:50:26 -07:00
Thileepan 1d9d1111e1 Environmental variables required for PHP cgi.
In few windows machines, the environment variables "ProgramFiles" is required to successfully execute PHP code especially socket functions.
2013-05-06 13:05:37 +05:30
Sergey Lyubka 2a0b55b30b mg_upload: trigger callback when file is already closed 2013-04-26 21:32:22 +01:00
Sergey Lyubka 1e3b167208 updated readme 2013-04-25 16:34:36 +01:00
Sergey Lyubka f7821b757c Updated README 2013-04-19 16:28:39 -07:00
Sergey Lyubka c352486abb Squashed warning in push() 2013-04-11 12:51:07 -07:00
Sergey Lyubka 4120b9bcc0 mg_get_cookie() signature change 2013-04-11 12:49:41 -07:00
Sergey Lyubka f7725f2eeb updated readme 2013-04-02 09:17:36 -07:00
Sergey Lyubka be06c3620c Updated readme 2013-03-28 18:46:15 -07:00
Sergey Lyubka 272644e39f mg_md5 returns char *, not void 2013-03-27 01:31:12 -07:00
Sergey Lyubka 55ef3afea4 Updated README 2013-03-24 09:06:52 -07:00
Sergey Lyubka 9e07c742ff Merge pull request #132 from hendrikp/master
Fixed crash and description for digest authentication
2013-03-19 10:54:05 -07:00
Hendrik Polczynski cd2e50c2c4 Update UserManual.md
fixed/extended global_auth_file description.
2013-03-19 17:52:17 +01:00
Hendrik Polczynski fdef2b8643 Update mongoose.c
when having connections with and without auth would cause double free and then crash
2013-03-19 17:42:21 +01:00
abadc0de ce55924a02 lsp_mg_read: remove dead code, return nil on empty read 2013-03-17 23:33:02 -04:00
Sergey Lyubka fbca54bcaf Updated readme 2013-03-17 07:53:03 -07:00
Sergey Lyubka 41c25d60d6 Updated README 2013-03-13 05:07:20 -07:00
Sergey Lyubka a9b5bb351f Added travis config 2013-03-11 07:25:11 -07:00
Sergey Lyubka 51ed3efcd1 Style fixes 2013-03-09 13:16:41 +00:00
Sergey Lyubka 67cffc8db5 Documented struct mg_callbacks 2013-03-09 13:12:03 +00:00
Sergey Lyubka 72abaa043b Documented struct mg_callbacks 2013-03-09 13:01:02 +00:00
Sergey Lyubka b3a511f9c5 Broken down cocoa target 2013-03-08 16:13:29 +00:00
Sergey Lyubka 8d1f6377c4 Changed websocket_data() handler API. Buffering and passing whole websocket message. 2013-03-08 16:03:23 +00:00
Sergey Lyubka 22dddc2eeb Merge pull request #124 from abadc0de/lua_err
Lua page error handling cleanup
2013-03-08 03:15:04 -08:00
Sergey Lyubka daab527743 Merge pull request #125 from bakwc/warnings
A little bit more warnings suppresed
2013-03-08 02:52:14 -08:00
Filipp Kovalev dd49c0791f A little bit more warnings suppresed 2013-03-08 14:41:17 +04:00
Sergey Lyubka 4b539d4b95 Suppressed some mingw warnings 2013-03-08 07:18:39 +00:00
Sergey Lyubka 5eabfe5da2 Using pijyoi's patch for connection close. 2013-03-08 07:08:09 +00:00
Sergey Lyubka 36b7c8d60d Forcing connection close when client disconnects. 2013-03-08 07:03:23 +00:00
abadc0de aa37b728ad Merge commit '10234' into lua_err 2013-03-07 03:02:15 -05:00
Sergey Lyubka 62085e5215 updated user manual 2013-03-06 13:37:01 +00:00
Sergey Lyubka d036f8a3f0 Merge pull request #118 from theaccordance/master
Added additional artwork files for Retina Display Support
2013-03-05 11:03:18 -08:00
Sergey Lyubka fb5e2b8c2f Setting off IPV6_V6ONLY for USE_IPV6 case 2013-03-05 18:55:33 +00:00
Sergey Lyubka 4505b00733 Removed support for option names 2013-03-05 18:26:10 +00:00
Sergey Lyubka c485b8264e Updated readme 2013-03-05 08:44:25 +00:00
Joseph Mainwaring 8edd710c00 Added additonal icon files to support Retina displays 2013-03-03 20:32:08 -06:00
Sergey Lyubka 3984e9f5cc Grammar in user manual 2013-03-02 10:34:28 +00:00
Sergey Lyubka d4fa794c83 Added mongoose internals section 2013-03-02 10:30:47 +00:00
Sergey Lyubka 3892e0199e Passing user_data to init_ssl() 2013-02-28 09:12:52 +00:00
Sergey Lyubka 67f5de624e updated readme 2013-02-28 08:09:39 +00:00
abadc0de 10234b07c4 Remove dead code 2013-02-27 16:33:05 -05:00
abadc0de 36a83e1452 Merge https://github.com/valenok/mongoose 2013-02-27 15:32:43 -05:00
abadc0de 34df4ec1fd Fix mg.onerror returns non-zero to stop processing 2013-02-27 15:29:18 -05:00
Sergey Lyubka 69cb94f3fb Removed header printing from page.lp 2013-02-27 18:06:35 +00:00
Sergey Lyubka 7204d71136 Merge pull request #102 from abadc0de/master
Better error handling and an include function for lua pages
2013-02-27 03:27:28 -08:00
Sergey Lyubka 283f590349 Merge pull request #106 from BusyJay/feature-2
Fix bugs about range request and explorer crashes
2013-02-27 03:21:33 -08:00
Sergey Lyubka 27735f293b Updated dates 2013-02-27 11:17:33 +00:00
Sergey Lyubka a560334fbb Merge pull request #111 from dpsk/lua_docs
Lua docs
2013-02-27 03:10:14 -08:00
Mikhail Nikalyukin cd1707034c update README.md 2013-02-27 13:04:08 +02:00
Mikhail Nikalyukin 5ce1fc3c2a add lua page example with the form submitting 2013-02-27 13:02:39 +02:00
Sergey Lyubka c78fe425a0 Updated Lua section in user manual 2013-02-27 10:49:31 +00:00
Sergey Lyubka a58bb71c19 Added Lua section to the user manual 2013-02-27 10:44:59 +00:00
Sergey Lyubka fc9a9593d2 Added sqlite to linux_lua target 2013-02-27 10:44:42 +00:00
Sergey Lyubka eb1fdf56e6 Updated readme 2013-02-26 11:47:46 +01:00
abadc0de ab960df8a9 Lua call stack cleanup 2013-02-25 20:48:36 -05:00
abadc0de 08048bd5bb Merge https://github.com/valenok/mongoose 2013-02-25 16:23:50 -05:00
abadc0de 800517ac16 Added support for lua error handling and includes
- Added mg.onerror, mg.include, mg.redirect
- mg.onerror, if overridden, lets the user trap syntax errors and
  other loadbuffer errors, and dump stack traces and debug info
  for uncaught runtime errors.
- Log unexpected errors from mg.onerror handlers
- Provide mg.cry so custom handlers can reproduce default behavior
- Call mg.onerror handler before unwinding stack
- If mg.onerror returns non-0, stop loading chunks
- Included pages stop parent page processing if mg.onerror returns non-zero
- Included pages don't sent HTTP errors, they throw lua errors
2013-02-25 16:19:38 -05:00
Jay 690eff4fa2 Fix bugs about range request and explorer crashes
1. fix a bug that when header contains "Range: 100-", the range request
support will fail
2. (windows) fix a bug that when explorer.exe crashes due to some
reason, the tray icon will disappear.
2013-02-25 22:17:46 +08:00
Sergey Lyubka e47b5b775a Squashed warning 2013-02-24 20:34:32 +00:00
Sergey Lyubka c15e2af897 Merge pull request #104 from pijyoi/warning-fix
minor fixes to reduce warnings in mingw
2013-02-24 12:28:23 -08:00
KIU Shueng Chuan d8536b011c portable socket type should be SOCKET 2013-02-24 23:41:32 +08:00
KIU Shueng Chuan a2239c2b4b squash mingw variable set but not used warning 2013-02-24 23:29:05 +08:00
KIU Shueng Chuan d3c02331d4 squash mingw printf format warning 2013-02-24 23:22:34 +08:00
Sergey Lyubka d707841166 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-02-24 07:58:21 +00:00
Sergey Lyubka affd82a885 updated readme 2013-02-24 07:56:41 +00:00
Sergey Lyubka 8322c82790 Merge pull request #103 from pijyoi/mingw-fix
avoid defining macros already present on mingw32
2013-02-23 00:52:08 -08:00
KIU Shueng Chuan 08708435a7 avoid defining macros already present on mingw32 2013-02-23 10:37:45 +08:00
Sergey Lyubka 1c6036c3ac Updated readme 2013-02-22 08:08:47 +00:00
Sergey Lyubka 6c3cb6f3eb Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-02-22 04:34:21 +00:00
Sergey Lyubka a123874ac5 Updated readme 2013-02-21 22:58:51 +00:00
Sergey Lyubka 7931929a42 Fix compile of mg_strcasestr() under windows 2013-02-18 10:49:03 +00:00
Sergey Lyubka cc4a4fb2ab Added http_error() to struct mg_callbacks 2013-02-16 15:26:11 +00:00
Sergey Lyubka 3d211d89c5 win32 mmap() must not close file handle, issue 99 2013-02-16 14:37:58 +00:00
Sergey Lyubka fbf1ccee45 Fix out-of-bounds acces in url_decode() 2013-02-16 14:31:37 +00:00
Sergey Lyubka 0bd43bcae3 Using mg_strcasestr() instead of strstr() 2013-02-16 14:17:38 +00:00
Sergey Lyubka b809665cad Squashed warning 2013-02-16 12:54:16 +00:00
Sergey Lyubka 463b49f1bd Fixed poll() issue with QNX 2013-02-16 12:54:02 +00:00
Sergey Lyubka a881aad5c6 Updated readme 2013-02-16 11:48:34 +00:00
Sergey Lyubka aae0995cd2 Updated README 2013-02-12 21:24:08 +00:00
Sergey Lyubka 26b3f227d9 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-02-12 21:04:42 +00:00
Sergey Lyubka 665770d602 cleaning up more files on make clean 2013-02-12 21:04:23 +00:00
Sergey Lyubka fcafaa73d6 Style fixes in the comments 2013-02-12 21:03:54 +00:00
Sergey Lyubka 079b9ec2c1 Added linux_lua target 2013-02-12 12:33:44 +00:00
Sergey Lyubka 7bd9a85897 Merge pull request #92 from jmucchiello/send_http_error
Send http error
2013-02-10 13:51:34 -08:00
Joe Mucchiello 2efc5d9fce http_error callback
Allow user to display status code errors
2013-02-10 15:58:06 -05:00
Joe Mucchiello 1cb094e059 Revert "Add http_error callback"
This reverts commit 27fe9c8f01.
2013-02-10 15:50:20 -05:00
Joe Mucchiello 27fe9c8f01 Add http_error callback
Allows user code to display its own error status responses or just log
the errors. Is called even in cases where begin_request is not called.
2013-02-10 15:02:37 -05:00
jmucchiello 9178fbd153 Merge pull request #1 from valenok/master
update
2013-02-10 11:51:24 -08:00
Sergey Lyubka b2b43ab0cd updated user manual 2013-02-10 16:27:19 +00:00
Sergey Lyubka 1415d187eb Added comments about auth checks done before begin_request() 2013-02-10 15:32:08 +00:00
Sergey Lyubka a65078b858 Calling begin_request() after auth checks. 2013-02-10 15:25:11 +00:00
Sergey Lyubka 7107afae5c updated readme 2013-02-10 15:00:34 +00:00
Sergey Lyubka f6a807c5a4 updated readme 2013-02-10 08:17:59 +00:00
Sergey Lyubka 47b11dd19e Updated README 2013-02-08 10:50:45 +00:00
Sergey Lyubka 61cdc93405 Updated README 2013-02-08 10:49:29 +00:00
Sergey Lyubka 7a52bd643c Updated manual 2013-02-08 10:45:40 +00:00
Sergey Lyubka 63e8052e4b Added index.lp to the index_files 2013-02-08 10:26:25 +00:00
Sergey Lyubka 782d0cda46 Updated user manual 2013-02-08 10:10:02 +00:00
Sergey Lyubka 72803eb7f8 num_threads 20 -> 50 2013-02-08 10:09:53 +00:00
Sergey Lyubka c7fd221ab7 Updated README 2013-02-08 09:17:59 +00:00
Sergey Lyubka 492185e35f Updated README 2013-02-08 09:17:21 +00:00
Sergey Lyubka 845d7b08e1 Fixed assert for keepalive code path 2013-02-08 08:21:52 +00:00
Sergey Lyubka 49bac31d2d Updated README 2013-02-08 08:21:05 +00:00
Sergey Lyubka 9baf2d4ba4 Using keep alive in unit test 2013-02-08 08:19:01 +00:00
Sergey Lyubka 1becd26a8f Updated readme 2013-02-07 20:58:37 +00:00
Sergey Lyubka ffa983552f 3.7 -> 3.8 2013-02-06 09:40:26 +00:00
Sergey Lyubka 13d0b67c00 More updates to User Manual 2013-02-05 18:00:49 +00:00
Sergey Lyubka bda8e90733 Added protection against running under launchd 2013-02-05 17:59:56 +00:00
Sergey Lyubka fed2057a33 Added comment 2013-02-05 17:59:16 +00:00
Sergey Lyubka a27f62f89f More options 2013-02-05 14:04:38 +00:00
Sergey Lyubka d53902844c Squashed warning for lua+sqlite code path 2013-02-04 22:14:42 +00:00
Sergey Lyubka 9870b80c65 Updated README 2013-02-04 20:18:07 +00:00
Sergey Lyubka cde25a8b82 Removed embedded test 2013-02-03 19:56:24 +00:00
Sergey Lyubka 1b7f036199 Removed embedded test 2013-02-03 19:56:16 +00:00
Sergey Lyubka b80157b7ea Setting user data pointer properly 2013-02-03 19:15:27 +00:00
Sergey Lyubka f9311f0b30 Building cocoa version with lua + sqlite 2013-02-02 16:42:01 +00:00
Sergey Lyubka bdd933f597 Fixed UNIX code path for handle_lsp_request() 2013-02-02 16:41:43 +00:00
Sergey Lyubka ee55d38b55 API CHANGE: using struct mg_callbacks 2013-02-01 16:48:30 +00:00
Sergey Lyubka 62162ff3e4 Added /DNO_SSL_DL to w target 2013-02-01 13:53:31 +00:00
Sergey Lyubka 98f66c8867 Updated User Manual 2013-01-31 22:33:08 +00:00
Sergey Lyubka c132191cad Prepare to change the API to use explicit callbacks 2013-01-31 18:29:22 +00:00
Sergey Lyubka d73aa1ad09 Added skeleton for regex checks 2013-01-31 18:06:05 +00:00
Sergey Lyubka d5bc58c38d Using sqlite as an example 2013-01-31 15:17:40 +00:00
Sergey Lyubka 51a80e4844 Do not output headers when serving Lua server pages 2013-01-31 15:17:19 +00:00
Sergey Lyubka 54f15a8fe3 Adding lua+sqlite functionality in the default windows binary build 2013-01-31 13:38:57 +00:00
Sergey Lyubka ce0826e285 Adding lua+sqlite functionality in the default windows binary build 2013-01-31 13:38:32 +00:00
Sergey Lyubka b21a8b2193 Removed wait_until_socket_is_readable(). Rely on socket timeout. 2013-01-29 11:21:23 +00:00
Sergey Lyubka 8bb49642da Merge pull request #86 from thekvs/master
I've just fixed a typo.
2013-01-28 12:06:28 -08:00
Konstantin Sorokin 3f78df86ac fixed typo 2013-01-28 18:49:19 +04:00
Sergey Lyubka c30f7a5258 Merge pull request #77 from bamiaux/add_request_timeout
Add request_timeout option
2013-01-28 03:13:28 -08:00
Sergey Lyubka 7ed94d1918 Unit test call fixed 2013-01-27 20:49:30 +00:00
Sergey Lyubka dc513a9a15 Wrapped SSL code into #ifndef NO_SSL 2013-01-27 20:49:17 +00:00
Sergey Lyubka 8ce6cf61b7 Using relative path to yassl 2013-01-27 20:48:52 +00:00
Sergey Lyubka e63f7fe33a Always initializing struct file on stack 2013-01-25 21:50:00 +00:00
Sergey Lyubka b589e0cdf4 Fixed mg_upload() and some SSL related issues 2013-01-25 20:28:09 +00:00
Sergey Lyubka 2b87f909ce Makefile refactored 2013-01-25 20:27:52 +00:00
Sergey Lyubka ec7d0b1abd Added test_mg_upload() 2013-01-25 20:27:08 +00:00
Sergey Lyubka 5bb3ede46d Removed mongoose.1 2013-01-25 13:21:19 +00:00
Sergey Lyubka 5105717f78 Added printf checkers for mg_download 2013-01-24 09:35:54 +00:00
Sergey Lyubka 9d1e356709 changed README 2013-01-24 09:35:11 +00:00
Sergey Lyubka 3d7192d9fa Typo in mongoose.h fixed 2013-01-24 01:16:23 +00:00
Sergey Lyubka 1b3cbb17c1 Updated README 2013-01-23 23:48:07 +00:00
Sergey Lyubka f1f03e4378 Updated README 2013-01-23 23:43:59 +00:00
Sergey Lyubka 625a2a3652 Updated README 2013-01-23 23:42:46 +00:00
Sergey Lyubka 33a31d9308 Updated README 2013-01-23 23:39:55 +00:00
Sergey Lyubka 5e9bd1f05e Update README.md 2013-01-23 23:34:01 +00:00
Sergey Lyubka 75d9a6c844 Removed mg_connect() and mg_fetch(). Added mg_download() 2013-01-23 21:54:27 +00:00
Sergey Lyubka 179761fd99 Removed LUA_FLAGS from CL flags 2013-01-23 21:14:11 +00:00
Sergey Lyubka b783813e54 Always sending MG_NEW_REQUEST, as first step in processing the request 2013-01-22 12:28:22 +00:00
Sergey Lyubka 4b29689a42 Binding to 127.0.0.1 to prevent popup windows on mac 2013-01-22 12:26:56 +00:00
Sergey Lyubka 9c4853471c Added stub for test_mg_upload() 2013-01-22 09:08:00 +00:00
Sergey Lyubka 81e21a3a0b Using get_url_to_first_open_port() in cocoa build 2013-01-22 09:00:17 +00:00
Sergey Lyubka bec6ea00ea Using unit test targets 2013-01-22 08:59:42 +00:00
Sergey Lyubka ed32e3be0f Added unix_unit_test and windows_unit_test targets 2013-01-22 08:59:13 +00:00
Sergey Lyubka 83fae879bf Binding to 127.0.0.1 to prevent annoying popups on mac 2013-01-21 22:29:31 +00:00
Sergey Lyubka 2169e6d77f Added -pthread to the CFLAGS 2013-01-21 17:51:56 +00:00
Sergey Lyubka 850e0a5922 Updated readme 2013-01-21 09:11:58 +00:00
Sergey Lyubka 322ed3cc6f fflush()-ing uploaded file before calling MG_UPLOAD callback 2013-01-21 01:39:14 +00:00
Sergey Lyubka 6d4d53c247 Squashed linux warning in process_new_connection() 2013-01-20 10:11:57 +00:00
Sergey Lyubka e6f8d40942 SSL redirect, using Host: header 2013-01-20 10:06:31 +00:00
Sergey Lyubka 7e051206ad Removed obsolete manual reference 2013-01-20 00:21:57 +00:00
Sergey Lyubka 76d913796c Getting first SSL listener dynamically 2013-01-19 22:32:26 +00:00
Sergey Lyubka 4c2609df2c Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-01-19 10:46:10 +00:00
Sergey Lyubka f79bd71fd4 Implemented ssl redirection 2013-01-19 10:45:58 +00:00
Sergey Lyubka 5d4f5b6000 Merge pull request #83 from rogerz/mingw-build-error
Fix building error under mingw
2013-01-18 05:36:50 -08:00
Rogerz Zhang fe7c245a6b Fix building error under mingw 2013-01-18 21:22:44 +08:00
Sergey Lyubka f24bebaca8 3.6 -> 3.7 2013-01-18 11:08:20 +00:00
Sergey Lyubka 08afdfa8b6 better cleanup 2013-01-18 10:43:52 +00:00
Sergey Lyubka 05f7d65fc9 Added "Start browser" menu item 2013-01-18 10:38:58 +00:00
Sergey Lyubka a194e07545 2011 -> 2013 2013-01-18 09:45:54 +00:00
Sergey Lyubka dbb8a5bbf4 put_delete_passwords_file -> put_delete_auth_file 2013-01-18 09:45:36 +00:00
Sergey Lyubka d3005df019 Bug fix in Win32 mg_mkdir 2013-01-17 17:51:59 +00:00
Sergey Lyubka ef9b103a00 Started adding ssl redirection support 2013-01-17 17:50:18 +00:00
Sergey Lyubka f0a2924a7c Added config editor for Win32 2013-01-17 17:14:41 +00:00
Sergey Lyubka f109030cd0 Renamed: global_passwords_file -> global_auth_file, put_delete_passwords_file -> put_delete_auth_file. 2013-01-17 17:14:11 +00:00
Sergey Lyubka eebdd06532 Added comdlg32.lib to GUILIB 2013-01-17 17:13:15 +00:00
Sergey Lyubka ca2fc71a01 Changed systray icon 2013-01-17 11:26:50 +00:00
Sergey Lyubka e61e371c16 Changed user manual 2013-01-17 11:20:59 +00:00
Sergey Lyubka d5f07f5b9b Changed README 2013-01-17 11:07:53 +00:00
Sergey Lyubka 0a8d5dde51 Changed README 2013-01-17 10:59:42 +00:00
Sergey Lyubka 5646caa572 Using poll() instead of select() to prevent FD_SETSIZE overflows, for programs that open large number of descriptors 2013-01-16 23:45:03 +00:00
Sergey Lyubka c7e5573d08 Not building DLLs. Using separate target for cocoa mac app. 2013-01-16 23:43:06 +00:00
Sergey Lyubka b9a226d109 Adding command line options 2013-01-15 13:53:25 +00:00
Sergey Lyubka fcf8b86288 Adding command line options 2013-01-15 13:51:35 +00:00
Sergey Lyubka a8b08c6784 Fixing http://code.google.com/p/mongoose/issues/detail?id=392 2013-01-15 13:24:53 +00:00
Sergey Lyubka 1fb6f391a1 In mg_upload(), use fopen() with "wb" mode instead of "wbx", cause "x" is not understood by Mac and Windows. 2013-01-13 10:55:42 +00:00
Sergey Lyubka fcbc36ecde return 0; after PostQuitMessage() 2013-01-10 16:26:01 +00:00
Sergey Lyubka 70771f29ce Config edit implemented for mac 2013-01-10 16:24:42 +00:00
Sergey Lyubka 121391504f mongoose.app -> Mongoose.app 2013-01-10 16:24:12 +00:00
Sergey Lyubka 8455742440 Pass reply status code to MG_REQUEST_COMPLETE 2013-01-10 09:56:24 +00:00
Sergey Lyubka 5b786a5089 make release corrected 2013-01-09 21:21:04 +00:00
Sergey Lyubka a6e74e7707 3.5 -> 3.6 2013-01-09 20:55:21 +00:00
Benoît Amiaux acf72a6109 Add request_timeout option 2013-01-09 17:09:04 +01:00
Sergey Lyubka 2b76f5fc2a removed 2013-01-09 15:50:31 +00:00
Sergey Lyubka c0150606f0 Removed bindings from the Makefile 2013-01-09 15:48:38 +00:00
Sergey Lyubka cdb6588973 Fix to stop misbehaving clients to DoS mongoose 2013-01-09 14:30:25 +00:00
Sergey Lyubka eecf24b20c Improved CGI disclosure protection 2013-01-09 14:24:50 +00:00
Sergey Lyubka 0470e813a9 renamed 2013-01-05 10:12:08 +00:00
Sergey Lyubka 52c2b6a407 renamed 2013-01-05 10:11:52 +00:00
Sergey Lyubka d0ce4b9d81 Added 2013-01-05 10:08:21 +00:00
Sergey Lyubka f08af96294 Updated user manual 2013-01-04 22:02:08 +00:00
Sergey Lyubka 315ab663df Update README.md 2013-01-04 21:25:58 +00:00
Sergey Lyubka fbd46f9b1c Updated user manual 2013-01-04 21:05:55 +00:00
Sergey Lyubka 74c099fe63 Updated user manual 2013-01-04 21:04:54 +00:00
Sergey Lyubka 2acfab62f0 Updated user manual 2013-01-04 21:01:13 +00:00
Sergey Lyubka 0f9a6266e2 Updated user manual 2013-01-04 17:37:19 +00:00
Sergey Lyubka ca447d9a23 Updated user manual 2013-01-04 17:33:55 +00:00
Sergey Lyubka 444dbe1cec Updated user manual 2013-01-04 17:29:47 +00:00
Sergey Lyubka 20ce55eb3a Using consistent date format 2013-01-03 22:42:14 +00:00
Sergey Lyubka 3956aba429 Correctedfor UserManual 2013-01-03 22:39:48 +00:00
Sergey Lyubka 6a37f5e4d6 Local reference for UserManual 2013-01-03 22:36:53 +00:00
Sergey Lyubka f71bfd5e28 Added skeleton for the user manual 2013-01-03 22:36:10 +00:00
Sergey Lyubka 38cc14a1af Initial version for the Macos app bundle 2013-01-03 15:46:47 +00:00
Sergey Lyubka bde9a63390 Endianess patch by Forrest 2013-01-03 10:29:34 +00:00
Sergey Lyubka 8eb816c314 Added icons 2013-01-03 08:42:32 +00:00
Sergey Lyubka 50c05c4eed Renamed win32 -> build 2013-01-02 18:21:46 +00:00
Sergey Lyubka 4eb5cfab7b Renamed win32 -> build 2013-01-02 18:15:36 +00:00
Sergey Lyubka df6fe7a379 Merge branch 'master' of ssh://github.com/valenok/mongoose 2013-01-02 17:53:01 +00:00
Sergey Lyubka 78eec961a2 Removing bindings code, because of inability to provide support for it 2013-01-02 17:51:12 +00:00
Sergey Lyubka adff33c889 Removing bindings code, because of inability to provide support for it 2013-01-02 17:51:01 +00:00
Sergey Lyubka 372fcd722c Update README.md 2013-01-02 14:06:28 +00:00
Sergey Lyubka 0982863e2d Update README.md 2013-01-02 13:50:27 +00:00
Sergey Lyubka 9b58a951f0 Update README.md 2013-01-02 13:48:40 +00:00
Sergey Lyubka ba04f3fd5d Update README.md 2013-01-02 13:35:30 +00:00
Sergey Lyubka ff52367c1c Update README.md 2013-01-02 13:34:07 +00:00
Sergey Lyubka a0a017d54d Update README.md 2013-01-02 13:32:07 +00:00
Sergey Lyubka 6cad2c6f28 Update README.md 2013-01-02 13:29:29 +00:00
Sergey Lyubka cec98ee9e2 Update README.md 2013-01-01 23:11:15 +00:00
Sergey Lyubka dbef400762 Mission statement 2013-01-01 23:05:09 +00:00
Sergey Lyubka 1bd85de19a Update README.md 2012-12-31 11:22:35 +00:00
Sergey Lyubka 0b206129ac Update README.md 2012-12-26 12:21:18 +00:00
Sergey Lyubka 5e491801da 3.4 -> 4.5 2012-12-26 10:02:14 +00:00
Sergey Lyubka eed09600f7 Ignoring .htpasswd file for PUT and DELETE requests. Those use separate passwords file. 2012-12-25 11:49:41 +00:00
Sergey Lyubka 8d6634ff7e Allowing HEAD method for CGI requests 2012-12-25 11:22:48 +00:00
Sergey Lyubka 6c9ed3ca53 Changed GetFullPathName -> GetFullPathNameA 2012-12-25 11:08:03 +00:00
Sergey Lyubka ede1befffa Fix read_websocket() for content length > 125 2012-12-25 11:05:19 +00:00
Sergey Lyubka 2cd4852321 Restore SIGCHLD handler to SIG_DFL in CGI process 2012-12-25 11:00:29 +00:00
Sergey Lyubka 1eb719f2d9 Checking for endianness in runtime in MD5 and SHA code 2012-12-24 21:23:34 +00:00
Sergey Lyubka bf633082ac Update README.md 2012-12-24 14:09:48 +00:00
Sergey Lyubka 075a152779 Update README.md 2012-12-24 11:09:44 +00:00
Sergey Lyubka c079a13b24 Update README.md 2012-12-24 11:09:23 +00:00
Sergey Lyubka 113c9d5a02 Fix keep-alive handling in process_new_connection() 2012-12-24 11:01:56 +00:00
Sergey Lyubka 05fa677382 Fixed unit test to accomodate mg_get_var() API change 2012-12-24 10:43:15 +00:00
Sergey Lyubka ab3c070e1c Merge pull request #66 from nullable-type/master
Made behavior of mg_get_cookie(..) regarding errors the same as of mg_get_var(..)
2012-12-23 04:40:35 -08:00
Sergey Lyubka 2e6a01b931 Fix for the relative document root & PHP 2012-12-22 18:24:48 +00:00
Sergey Lyubka 9fa66bf237 Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-12-22 08:55:36 +00:00
Sergey Lyubka 98c382e7af Merge pull request #67 from tayS/ssl_pending
Fix for hang when sending large request with SSL enabled
2012-12-22 00:55:07 -08:00
Sergey Lyubka 94c7a3862a Update README.md 2012-12-21 21:47:14 +00:00
tayS 6869b64b31 Fix for hang when sending large request with SSL enabled
When using SSL, we must use SSL_pending() in addition to/instead of select() to determine whether there is SSL data to be read.
This update makes the SSL_pending() function available and uses is to check for data if select() indicates there is no data.

See https://github.com/valenok/mongoose/issues/47
2012-12-21 12:38:34 -06:00
nullable.type 8faf6f7b72 Made behavior of mg_get_cookie(..) on errors the same as mg_get_var(..). Separated the two cases a.) problems with destination buffer and b.) cookie header or cookie parameter not existing. 2012-12-16 22:20:21 +01:00
Sergey Lyubka 99ddb2f12a Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-12-16 13:09:08 +00:00
Sergey Lyubka ca9212c3ca Merge pull request #65 from nullable-type/master
Inconsistent error codes of mg_get_var(..)
2012-12-16 04:15:52 -08:00
nullable.type c9183f3851 Made the names of the function arguments of the declaration and the definition of mg_get_var(..) the same.
Changed the error codes to have a consistent way of reporting errors. -2 is returned if there is a problem with the size of the destination buffer. -1 is returned if the variable is not found.

Updated the documentation of mg_get_var(..) in mongoose.h and removed the redundant comments from mongoose.c.
2012-12-16 12:27:53 +01:00
Sergey Lyubka 0912a7f473 Merge pull request #60 from bakanatorz/master
Added support for Ogg Vorbis audio files
2012-12-09 13:26:57 -08:00
Sergey Lyubka 38421657b3 Minor refactoring in examples/upload.c 2012-12-08 14:53:46 +00:00
Sergey Lyubka 64cfe1d389 Merge pull request #49 from nullable-type/master
Avoid some level-4 warnings issued by Visual Studio (2012 and possibly previous versions)
2012-12-08 06:47:35 -08:00
Sergey Lyubka 69b0b58d46 Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-12-07 01:50:52 +00:00
Sergey Lyubka 0d442058e5 Added mg_upload() 2012-12-07 01:50:47 +00:00
Sergey Lyubka 1ef31461bc Added test_skip_quoted() 2012-12-07 01:50:12 +00:00
Sergey Lyubka 0b09df97ac On new connection, clear off receiving buffer 2012-12-05 23:07:20 +00:00
Sergey Lyubka 0263e39584 Minor refactoring 2012-11-30 15:01:15 +00:00
Sergey Lyubka d8424726bb Using O_BINARY on win32 for uploaded files 2012-11-30 10:09:39 +00:00
Sergey Lyubka 080cb2dd4b Changed signature of url_decode(): signalling on destination buffer overflow. mg_get_var() now does not require extra space for variable buffer 2012-11-14 09:26:02 -08:00
Eric Bakan 786caaecb2 Added support for Ogg Vorbis audio files 2012-11-12 10:40:19 -05:00
nullable.type eb92b5f1b3 Avoid memory leaks if duplicate options are passed. 2012-11-02 22:52:47 +01:00
nullable.type c5ba6016aa Suppress warning C4127 (conditional expression is constant) issued by Visual Studio 2012 introduced by FD_SET(..) which is using the do-while(0) trick. 2012-10-27 14:09:26 +02:00
nullable.type 73a845a327 Suppress warning C4204 (non-constant aggregate initializer) issued by Visual Studio 2012 due to missing C99 support. 2012-10-27 14:07:06 +02:00
nullable.type 6eec552ea4 Added declaration to avoid warning C4115 (named type definition in parentheses) issued by Visual Studio 2012. 2012-10-27 14:04:41 +02:00
Sergey Lyubka cb62203cf3 More documentation for MG_OPEN_FILE event 2012-10-25 21:47:04 +01:00
Sergey Lyubka 4fcb64fe90 Fix exception in win32 code path when CGI exec fails 2012-10-24 10:12:32 +01:00
Sergey Lyubka 8966f47c7a Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-10-23 20:21:38 +01:00
Sergey Lyubka e251375c0c Using .lp extension for Lua server pages 2012-10-23 20:21:24 +01:00
Sergey Lyubka 672e1ec8c6 Merge pull request #44 from mitchh/master
Fix 30s hang->timeout when closing a socket with no more data
2012-10-20 00:39:51 -07:00
Mitch Hendrickson f8713ede2d Use existing must_close flag instead of adding is_closing 2012-10-19 19:51:01 -07:00
Mitch Hendrickson 0b5f854bf0 Fix 30s timeout when closing a socket that has no remaining data, introduced in 375950f6; setting the socket nonblocking makes recv() return instantly but not select() 2012-10-15 23:09:14 -07:00
Sergey Lyubka 3770020b74 Remove winsock include - windows.h does that for us 2012-10-14 15:08:43 +01:00
Sergey Lyubka 9f9a1638f7 clean target added 2012-10-14 15:00:04 +01:00
Sergey Lyubka fb07a937e7 Merge pull request #43 from sebbern/master
Winsock2.h included after windows.h
2012-10-13 04:35:06 -07:00
Sebastian Reinhard 025cd283c4 Fixed an error in mongoose.c that caused a lot of errors where winsock2.h was included after windows.h 2012-10-13 12:47:51 +02:00
Sergey Lyubka b39426dbf7 Showing error message 2012-10-12 14:28:35 +01:00
Sergey Lyubka 5157bd0960 Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-10-10 15:12:30 +01:00
Sergey Lyubka 2aaedef4af Trimming whitespaces properly in windows CGI interpreter name 2012-10-10 15:12:16 +01:00
Sergey Lyubka a0b037d288 Merge pull request #39 from shantanugadgil/patch-1
Add mime type for .xsl
2012-10-08 00:53:50 -07:00
shantanugadgil 011bdc22b2 Update mongoose.c
Add default MIME type for xsl
2012-10-08 09:55:33 +05:30
Sergey Lyubka b437d56736 Added MG_INIT_LUA event 2012-10-08 00:09:43 +01:00
Sergey Lyubka 6205e69ab2 Fixed python bindings 2012-10-07 16:26:04 +01:00
Sergey Lyubka 038f8823f1 Added test to mg_stat(). Fixed set_gpass() 2012-10-05 08:58:13 +01:00
Sergey Lyubka 03dd8367bf Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-10-05 02:10:47 +01:00
Sergey Lyubka b597da34da Pass user_data to the callback 2012-10-05 02:10:35 +01:00
Sergey Lyubka bf387f9544 Added Lua build instructions 2012-10-01 22:24:22 +01:00
Sergey Lyubka 365b5e8f8a Using long for file size in MG_OPEN_FILE ev_data 2012-10-01 10:19:20 +01:00
Sergey Lyubka 47651766fb Squashed warning under linux 2012-09-30 16:35:09 +01:00
Sergey Lyubka 043ea54a2a Removed test cruft for MG_OPEN_FILE message from the event handler 2012-09-29 22:24:16 +01:00
Sergey Lyubka 55c8c82c4b Fixed windows build 2012-09-29 22:21:10 +01:00
Sergey Lyubka 557d1f4c49 Added MG_OPEN_FILE message 2012-09-29 18:56:41 +01:00
Sergey Lyubka 2539a473fe Added test for byte range past EOF 2012-09-29 18:56:23 +01:00
Sergey Lyubka 6bd35a4c18 Style changes 2012-09-28 10:36:31 +01:00
Sergey Lyubka fb8f0ed4d6 Better comments in Makefile 2012-09-27 23:58:35 +01:00
Sergey Lyubka 3ffdf5459a API change: folded user_data into request_info, and introduced event-specific ev_data 2012-09-27 22:20:02 +01:00
Sergey Lyubka 02098b1903 API change: folded user_data into request_info, and introduced event-specific ev_data 2012-09-27 21:48:05 +01:00
Sergey Lyubka c189553c8b Cosmetic changes for CYA_SOURCES 2012-09-27 08:27:45 +01:00
Sergey Lyubka d970705596 #define MAP_PRIVATE 0 for _WIN32 2012-09-27 08:19:14 +01:00
Sergey Lyubka 5c9ab40601 Using MAP_PRIVATE for mmap, to fix mac build for Lua 2012-09-27 08:17:31 +01:00
Sergey Lyubka 451d077170 cygwin target added 2012-09-27 00:33:33 +01:00
Sergey Lyubka 30d1573346 Fixed spawn_proccess() for win32 for .exe binaries 2012-09-27 00:27:20 +01:00
Sergey Lyubka 0adef2db5b Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-09-26 23:37:15 +01:00
Sergey Lyubka 8c1866a4af Lua server pages support 2012-09-26 23:37:03 +01:00
Sergey Lyubka 2a7a594b49 Squashed warning under linux 2012-09-25 12:35:30 +01:00
Sergey Lyubka 78ea04556f Windows build for examples added 2012-09-24 21:25:06 +01:00
Sergey Lyubka 7fe2944477 Squashed warnings in win32 websocket code 2012-09-24 21:24:02 +01:00
Sergey Lyubka 93131417e6 is_websocket_request() modified to check for the presence of keyword rather then euqality 2012-09-24 09:38:02 +01:00
Sergey Lyubka 6ef5eb0665 Changed overview 2012-09-24 09:04:28 +01:00
Sergey Lyubka 24103ff5df Added more things to features section 2012-09-23 15:06:09 +01:00
Sergey Lyubka 2118de37c3 3.3 -> 3.4 2012-09-23 15:02:18 +01:00
Sergey Lyubka 0804ce71d5 updated date on a manual page 2012-09-23 14:50:07 +01:00
Sergey Lyubka 2ffb558e30 nullify ssl_mutexes after free-ing them 2012-09-23 14:19:36 +01:00
Sergey Lyubka 05062be889 Fix for issue 257 2012-09-23 13:55:33 +01:00
Sergey Lyubka ba6c01e602 Fixed check_acl() 2012-09-23 13:50:36 +01:00
Sergey Lyubka dfc0f00478 Implement -T option, throttling functionality 2012-09-23 13:28:27 +01:00
Sergey Lyubka ecb2b0e53d Cleaner compilation for 16-bit targets 2012-09-23 02:13:53 +01:00
Sergey Lyubka ed74cd82f5 Added declarations for printf like functions 2012-09-23 01:35:59 +01:00
Sergey Lyubka d2be594262 defining PATH_MAX if not defined 2012-09-22 15:49:58 +01:00
Sergey Lyubka 1e632d3215 Removed "Content-Type: text/plain" header from send_http_error() response. 2012-09-22 15:21:21 +01:00
Sergey Lyubka 5642dfcf38 CGI handling on windows: constructing full path to the interpreter. enabling SO_REUSEADDR on listening socket. 2012-09-22 15:15:46 +01:00
Sergey Lyubka 4dff36ffde removed unused struct timespec 2012-09-22 13:36:24 +01:00
Sergey Lyubka 771ce9059c added 2012-09-22 13:31:10 +01:00
Sergey Lyubka e490b30c38 _mongoose.dll -> mongoose.dll 2012-09-22 13:15:05 +01:00
Sergey Lyubka f935ef832b _mongoose.dll -> mongoose.dll, _mongoose.so -> libbmongoose.so 2012-09-22 12:52:47 +01:00
Sergey Lyubka 79cdb77e5d Removed hard-coded CC value from Makefile 2012-09-22 12:27:20 +01:00
Sergey Lyubka ff0c2d3f91 Added unit test for mg_get_var 2012-09-22 12:22:30 +01:00
Sergey Lyubka 6f9901b65c config file parsing: allow blank lines 2012-09-22 11:29:50 +01:00
Sergey Lyubka bce3a85702 #including winsock2 and ws2tcpip headers by default on windows 2012-09-21 19:22:35 +01:00
Sergey Lyubka f741349d51 Fixed calculation of the number of leap days 2012-09-21 17:21:04 +01:00
Sergey Lyubka 25863b59a6 Sending MG_WEBSOCKET_CLOSE 2012-09-21 09:05:45 +01:00
Sergey Lyubka 72c861bb83 Python bindings synced 2012-09-21 09:05:12 +01:00
Sergey Lyubka 586574e176 Added #pragma comment(lib, "Ws2_32.lib") for win32 2012-09-21 09:03:47 +01:00
Sergey Lyubka 0f15954727 Skip SSL init if PEM file is not specified 2012-09-20 20:39:43 +01:00
Sergey Lyubka 167338f216 Using slash, "/" as the universal directory separator throughout the code 2012-09-20 18:20:41 +01:00
Sergey Lyubka d82f6b7607 Added /machine:IX86 to MSVC flags 2012-09-20 18:20:01 +01:00
Sergey Lyubka 614b219a27 Marking WRITE end of a pipe as closed in handle_cgi_request() 2012-09-20 17:22:22 +01:00
Sergey Lyubka 35cf8687df Merge pull request #32 from okigan/master
Compile on Windows
2012-09-20 08:45:31 -07:00
Sergey Lyubka d883b0f0f9 Prevent possible assert fail on windows in handle_cgi_request() 2012-09-20 15:11:38 +01:00
Sergey Lyubka 0b942aaaba Minor change for the win32 build 2012-09-20 14:55:09 +01:00
Sergey Lyubka 364235e7ae Squashed warning on windows 2012-09-20 14:54:51 +01:00
Sergey Lyubka ba1f2ced8e Cosmetic changes 2012-09-20 14:17:28 +01:00
Sergey Lyubka c4c34a8f4d Cosmetic changes 2012-09-20 14:17:04 +01:00
Sergey Lyubka a866f4e174 Cosmetic changes 2012-09-20 14:06:33 +01:00
Sergey Lyubka c5916814cd Added link to mongoose.c 2012-09-20 14:03:39 +01:00
Sergey Lyubka 349717ac0e removed stray new line 2012-09-20 14:02:33 +01:00
Sergey Lyubka 5d27766424 Added comment on the websocket example page 2012-09-20 14:01:45 +01:00
Sergey Lyubka 97668ba6c9 Updated README to reflect websocket and webdav support 2012-09-20 13:52:53 +01:00
Sergey Lyubka 98fb44f836 Refactored data buffering. Updated websocket example to have 2 message roundtrips. 2012-09-20 13:45:35 +01:00
Igor Okulist 2260c8ddc0 Merge branch 'master' of https://github.com/okigan/mongoose 2012-09-19 20:57:00 -07:00
Sergey Lyubka edffc46b98 removed -max_request_size option 2012-09-19 20:17:49 +01:00
Sergey Lyubka 7bd8cc3c0c added websocket example files 2012-09-19 12:31:19 +01:00
Sergey Lyubka 828f6cd7fe added link to the websocket example 2012-09-19 12:30:29 +01:00
Sergey Lyubka f9873eb87a Experimentl websocket support 2012-09-19 12:23:54 +01:00
Sergey Lyubka 358e4ffbf5 extra check in cry() for NULL context 2012-09-18 09:47:29 +01:00
Sergey Lyubka 9aad922983 added mg_get_ssl_context. passing fake connection to the MG_INIT_SSL event 2012-09-17 23:36:06 +01:00
Sergey Lyubka d9ab7af8b4 added comment in mongoose_callback 2012-09-17 23:35:11 +01:00
Sergey Lyubka 05b2a04267 moved status_code, user_data, log_message out of struct mg_request_info 2012-09-17 19:38:19 +01:00
Sergey Lyubka 4408083b4d removed ssl chain file option. restored context param in fc() call 2012-09-17 19:19:15 +01:00
Igor Okulist 4f01f101fc Compile on Win32 2012-09-15 20:40:28 -07:00
Sergey Lyubka d9f9911d9b removed max request size from options, moved to the #define 2012-09-15 10:58:50 +01:00
Sergey Lyubka 93b4562515 Added make target for upload example 2012-09-15 10:52:52 +01:00
Sergey Lyubka 0bb67e06c1 #define _XOPEN_SOURCE 600 only for linux 2012-09-15 10:51:35 +01:00
Sergey Lyubka 518b3aa726 Merge pull request #12 from nigels-com/master
Touch-ups for Regal build of mongoose
2012-09-14 03:28:20 -07:00
Sergey Lyubka 07f3554db3 Merge pull request #10 from nullable-type/master
Fix for issue 8
2012-09-14 02:30:50 -07:00
Sergey Lyubka acab70ee7c Updated readme to reference more examples 2012-09-14 10:27:43 +01:00
Sergey Lyubka c388bc2dd3 added upload example 2012-09-14 10:23:51 +01:00
Sergey Lyubka 8072b0a7d4 Do not report error if mg_printf() printed 0 bytes 2012-09-13 21:58:37 +01:00
Sergey Lyubka 3f4be595a6 Merge pull request #25 from siemens/master
Makefile for MinGW 4.7
2012-09-13 13:52:23 -07:00
Henrique Mendonça 5d11901af8 compile with MinGW 4.7 2012-09-13 19:39:02 +03:00
Sergey Lyubka 43953782f9 Do not require SSL, fix for issue 20 2012-09-06 10:06:30 +01:00
Sergey Lyubka 12e133a5e9 Merge branch 'master' of ssh://github.com/valenok/mongoose 2012-09-06 10:00:42 +01:00
Sergey Lyubka e92d4451ef fc() doesnt take ctx argument anymore 2012-09-06 09:54:39 +01:00
Sergey Lyubka fadb60d776 Merge pull request #17 from dnaeon/freebsd-fix
Fix building of mongoose under FreeBSD.
2012-09-04 02:26:19 -07:00
Marin Atanasov Nikolov 0521d78982 Fix building of mongoose under FreeBSD.
According to flockfile(3) under Linux you need only this:

    #define _XOPEN_SOURCE

* http://man7.org/linux/man-pages/man3/flockfile.3.html

This also fixes the build under FreeBSD.
2012-09-04 11:58:45 +03:00
Sergey Lyubka 3602d54a5b Better check for NULL in mg_connect() 2012-09-03 22:36:40 +01:00
Sergey Lyubka 8428f362c1 Added example for handling POST requests. 2012-08-31 09:24:34 +01:00
Nigel Stewart fafc9c6a20 Undefine WIN32_LEAN_AND_MEAN, if necessary.
Allow debug tracing to be disabled in debug-mode build by defining DEBUG_TRACE at compile-time.
2012-08-28 08:25:10 -05:00
test 66e088d843 Removed the test for a directory name with only a backslash, because this causes problems on windows. 2012-08-27 14:40:32 +02:00
Sergey Lyubka 4a760ad324 Initial version of readme 2012-08-25 22:48:14 +01:00
Sergey Lyubka c92d7c3bc8 Fix for Android: fread() might return < 0 2012-08-25 22:10:45 +01:00
Sergey Lyubka ee91109d9f Ger Hobbelt's fixes 2012-08-25 22:02:51 +01:00
Sergey Lyubka 30fe257691 Style fixes. Printing error message before fatal error. 2012-08-25 20:36:58 +01:00
Sergey Lyubka ab6f145e3e Update thread count on OOM error in worker_thread() 2012-08-25 20:24:09 +01:00
test 83dc425e25 Removed the test for a directory name with only a backslash, because this causes problems on windows. 2012-08-23 16:36:41 +02:00
Sergey Lyubka 001cd78b45 Styling changes plus extra GCC options to suppress certain warnings 2012-08-19 12:22:28 +01:00
Sergey Lyubka 3d3359910f Added printf format checking macros. Changed mg_printf() to allocate the buffer on heap if it does not fit the local one. 2012-08-19 12:08:33 +01:00
Sergey Lyubka ee8111e424 Unbreak backslash dir test 2012-08-19 12:06:35 +01:00
Sergey Lyubka 1861b1137b Merge pull request #5 from GerHobbelt/issue-g.c.370.get_request
backport of the relevant fix as per issue 370#c5: correct get_request under all circumstances
2012-08-18 13:06:13 -07:00
Ger Hobbelt ccf43fe3e3 backport of the relevant fix as per http://code.google.com/p/mongoose/issues/detail?id=370#c5 2012-08-18 21:44:29 +02:00
Sergey Lyubka 8b491d75b5 added const in mg_get_request_info() 2012-08-18 16:47:25 +01:00
Sergey Lyubka d70c18d692 3.2 -> 3.3 2012-08-17 21:42:25 +01:00
165 changed files with 166688 additions and 8139 deletions

No files matched your search

+13 -16
View File
@@ -1,19 +1,16 @@
Copyright (c) 2004-2010 Sergey Lyubka Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
Copyright (c) 2013-2015 Cesanta Software Limited
All rights reserved
Permission is hereby granted, free of charge, to any person obtaining a copy This software is dual-licensed: you can redistribute it and/or modify
of this software and associated documentation files (the "Software"), to deal it under the terms of the GNU General Public License version 2 as
in the Software without restriction, including without limitation the rights published by the Free Software Foundation. For the terms of this
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell license, see <http://www.gnu.org/licenses/>.
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 You are free to use this software under the terms of the GNU General
all copies or substantial portions of the Software. Public License, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR Alternatively, you can license this software under a commercial
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, license, as set out in <https://www.cesanta.com/license>.
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.
-146
View File
@@ -1,146 +0,0 @@
# This file is part of Mongoose project, http://code.google.com/p/mongoose
# $Id: Makefile 473 2009-09-02 11:20:06Z valenok $
PROG= mongoose
all:
@echo "make (linux|bsd|solaris|mac|windows|mingw)"
# Possible COPT values: (in brackets are rough numbers for 'gcc -O2' on i386)
# -DHAVE_MD5 - use system md5 library (-2kb)
# -DNDEBUG - strip off all debug code (-5kb)
# -DDEBUG - build debug version (very noisy) (+7kb)
# -DNO_CGI - disable CGI support (-5kb)
# -DNO_SSL - disable SSL functionality (-2kb)
# -DCONFIG_FILE=\"file\" - use `file' as the default config file
# -DHAVE_STRTOUI64 - use system strtoui64() function for strtoull()
# -DSSL_LIB=\"libssl.so.<version>\" - use system versioned SSL shared object
# -DCRYPTO_LIB=\"libcrypto.so.<version>\" - use system versioned CRYPTO so
##########################################################################
### UNIX build: linux, bsd, mac, rtems
##########################################################################
CFLAGS = -W -Wall -std=c99 -pedantic -O2 $(COPT)
MAC_SHARED = -flat_namespace -bundle -undefined suppress
LINFLAGS = -ldl -pthread $(CFLAGS)
LIB = _$(PROG).so
#CC = g++
# Make sure that the compiler flags come last in the compilation string.
# If not so, this can break some on some Linux distros which use
# "-Wl,--as-needed" turned on by default in cc command.
# Also, this is turned in many other distros in static linkage builds.
linux:
$(CC) mongoose.c -shared -fPIC -fpic -o $(LIB) $(LINFLAGS)
$(CC) mongoose.c main.c -o $(PROG) $(LINFLAGS)
bsd:
$(CC) mongoose.c -shared -pthread -fpic -fPIC -o $(LIB) $(CFLAGS)
$(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
mac:
$(CC) mongoose.c -pthread -o $(LIB) $(MAC_SHARED) $(CFLAGS)
$(CC) mongoose.c main.c -pthread -o $(PROG) $(CFLAGS)
solaris:
gcc mongoose.c -pthread -lnsl \
-lsocket -fpic -fPIC -shared -o $(LIB) $(CFLAGS)
gcc mongoose.c main.c -pthread -lnsl -lsocket -o $(PROG) $(CFLAGS)
##########################################################################
### WINDOWS build: Using Visual Studio or Mingw
##########################################################################
# Using Visual Studio 6.0. To build Mongoose:
# o Set VC variable below to where VS 6.0 is installed on your system
# o Run "PATH_TO_VC6\bin\nmake windows"
VC= z:
CYA= y:
#DBG= /Zi /DDEBUG /Od
DBG= /DNDEBUG /O1
CL= cl /MD /TC /nologo $(DBG) /Gz /W3 /DNO_SSL_DL
GUILIB= user32.lib shell32.lib
LINK= /link /incremental:no /libpath:$(VC)\lib /subsystem:windows \
ws2_32.lib advapi32.lib cyassl.lib
CYAFL = /c /I $(CYA)/include -I $(CYA)/include/openssl \
/I $(CYA)/ctaocrypt/include /D _LIB /D OPENSSL_EXTRA
CYASRC= \
$(CYA)/src/cyassl_int.c \
$(CYA)/src/cyassl_io.c \
$(CYA)/src/keys.c \
$(CYA)/src/tls.c \
$(CYA)/src/ssl.c \
$(CYA)/ctaocrypt/src/aes.c \
$(CYA)/ctaocrypt/src/arc4.c \
$(CYA)/ctaocrypt/src/asn.c \
$(CYA)/ctaocrypt/src/coding.c \
$(CYA)/ctaocrypt/src/ctc_asm.c \
$(CYA)/ctaocrypt/src/ctc_misc.c \
$(CYA)/ctaocrypt/src/cyassl_memory.c \
$(CYA)/ctaocrypt/src/des3.c \
$(CYA)/ctaocrypt/src/dh.c \
$(CYA)/ctaocrypt/src/dsa.c \
$(CYA)/ctaocrypt/src/ecc.c \
$(CYA)/ctaocrypt/src/hc128.c \
$(CYA)/ctaocrypt/src/hmac.c \
$(CYA)/ctaocrypt/src/integer.c \
$(CYA)/ctaocrypt/src/md4.c \
$(CYA)/ctaocrypt/src/md5.c \
$(CYA)/ctaocrypt/src/pwdbased.c \
$(CYA)/ctaocrypt/src/rabbit.c \
$(CYA)/ctaocrypt/src/random.c \
$(CYA)/ctaocrypt/src/ripemd.c \
$(CYA)/ctaocrypt/src/rsa.c \
$(CYA)/ctaocrypt/src/sha.c \
$(CYA)/ctaocrypt/src/sha256.c \
$(CYA)/ctaocrypt/src/sha512.c \
$(CYA)/ctaocrypt/src/tfm.c
cyassl:
$(CL) $(CYASRC) $(CYAFL) $(DEF)
lib *.obj /out:cyassl.lib
windows:
rc win32\res.rc
$(CL) main.c mongoose.c /GA $(LINK) win32\res.res \
$(GUILIB) /out:$(PROG).exe
$(CL) mongoose.c /GD $(LINK) /DLL /DEF:win32\dll.def /out:_$(PROG).dll
# Build for Windows under MinGW
#MINGWDBG= -DDEBUG -O0
MINGWDBG= -DNDEBUG -Os
#MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT
MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,windows $(MINGWDBG)
mingw:
windres win32\res.rc win32\res.o
gcc $(MINGWOPT) mongoose.c -lws2_32 \
-shared -Wl,--out-implib=$(PROG).lib -o _$(PROG).dll
gcc $(MINGWOPT) mongoose.c main.c win32\res.o -lws2_32 -ladvapi32 \
-o $(PROG).exe
##########################################################################
### Manuals, cleanup, test, release
##########################################################################
man:
groff -man -T ascii mongoose.1 | col -b > mongoose.txt
groff -man -T ascii mongoose.1 | less
# "TEST=unit make test" - perform unit test only
# "TEST=embedded" - test embedded API by building and testing test/embed.c
# "TEST=basic_tests" - perform basic tests only (no CGI, SSI..)
test: do_test
do_test:
perl test/test.pl $(TEST)
release: clean
F=mongoose-`perl -lne '/define\s+MONGOOSE_VERSION\s+"(\S+)"/ and print $$1' mongoose.c`.tgz ; cd .. && tar -czf x mongoose/{LICENSE,Makefile,bindings,examples,test,win32,mongoose.c,mongoose.h,mongoose.1,main.c} && mv x mongoose/$$F
clean:
rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz
+104
View File
@@ -0,0 +1,104 @@
# <img src="http://www.cesanta.com/hubfs/www.cesanta.com/Images/mongoose_library.png" width="64" height="64"> Mongoose - Embedded Web Server
![](https://img.shields.io/badge/license-GPL_2-green.svg "License")
Mongoose is ideal for embedded environments. It has been designed
for connecting devices and bringing them online.
[Mongoose](https://www.cesanta.com/products)
has been on the market since 2004 and attracted
over 1 million cumulative downloads.
It provides easy to use event-driven interface that allows to implement
network protocols or scalable network applications with little effort.
Mongoose helps developers to manage the complexity of network programming
and let them concentrate on the logic, saving time and money.
- [Download Mongoose Source Code here](http://hubs.ly/H01bWvx0)
- [Ask questions on support forum](http://forum.cesanta.com/index.php?p=/categories/mongoose)
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose)
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)
> Nothing overdone. Nothing less. So unbelievably easy to use.
> Just how good software should be! -- Pritin Tyagaraj, SAP
# Features
* Cross-platform: works on Linux/UNIX, MacOS, QNX, eCos, Windows, Android,
iPhone, FreeRTOS (TI CC3200, ESP8266), etc
* Single-threaded, asynchronous, non-blocking core with simple event-based API
* Native support for [PicoTCP embedded TCP/IP stack](http://www.picotcp.com),
[LWIP embedded TCP/IP stack](https://en.wikipedia.org/wiki/LwIP)
* Builtin protocols:
- plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
- HTTP client, HTTP server
- Websocket client, Websocket server
- JSON-RPC client, JSON-RPC server
- MQTT client, MQTT broker
- CoAP client, CoAP server
- DNS client, DNS server, async DNS resolver
* Tiny static and run-time footprint
* Source code is both ISO C and ISO C++ compliant
* Very easy to integrate: just copy
[mongoose.c](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c) and
[mongoose.h](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.h)
files to your build tree
* Extensively tested and production-ready, trusted by many blue chip businesses
# Dashboard Example
Mongoose is often used to implement device dashboards and real-time
data exchange over Websocket. Here is a dashboard example that illustrates
the functionality:
![](http://www.cesanta.com/hubfs/www.cesanta.com/diagrams/dash_mongoose_diagram.png)
[Developing a new product? Contact us today to discuss how Mongoose can help
](https://www.cesanta.com/contact)
# Contributions
People who have agreed to the
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
can make contributions. Note that the CLA isn't a copyright
_assigment_ but rather a copyright _license_.
You retain the copyright on your contributions.
# Licensing
You are using Mongoose under
[GPLv2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
and until you commercialize your
application, can continue to use Mongoose free of charge.
Once you commercialize your product, in order to comply with GPLv2
you need to either open the source code of your product fully or
alternatively purchase a commercial license.
We offer [three levels of commercial licensing](https://www.cesanta.com/products):
- Mongoose Lite: cross platform integration, SSL/TLS, HTTP support
- Mongoose: Mongoose Lite + HTTP CGI, HTTP SSI, HTTP Digest Auth,
WebSocket support
- Mongoose Premium: Mongoose + Plain TCP, UDP, JSON-RPC, MQTT, DNS,
CoAP support
[Enquire about commercial licensing here](https://www.cesanta.com/contact)
# Mongoose Binary
This is our easy to use web server for web developers (PHP, Ruby, Python, etc)
and web designers. Available in three editions to suit your needs: free, pro
(USD 5) and dev edition (from USD 8). To install, simply download, double-click
to start and run browser - that's all!
[Download Mongoose Binary here](https://www.cesanta.com/products#binary)
# Other products by Cesanta
- [Smart.js](https://github.com/cesanta/smart.js) -
Generic, hardware independent, full-stack IoT software platform
- [V7](https://github.com/cesanta/v7) - Embedded JavaScript engine
- [Frozen](https://github.com/cesanta/frozen) - JSON parser and generator
- [SLRE](https://github.com/cesanta/slre) - Super Light Regular Expression
library
-52
View File
@@ -1,52 +0,0 @@
// This is C# example on how to use Mongoose embeddable web server,
// http://code.google.com/p/mongoose
//
// Before using the mongoose module, make sure that Mongoose shared library is
// built and present in the current (or system library) directory
using System;
using System.Runtime.InteropServices;
public class Program {
// This function is called when user types in his browser http://127.0.0.1:8080/foo
static private void UriHandler(MongooseConnection conn, MongooseRequestInfo ri) {
conn.write("HTTP/1.1 200 OK\r\n\r\n");
conn.write("Hello from C#!\n");
conn.write("Your user-agent is: " + conn.get_header("User-Agent") + "\n");
}
static private void UriDumpInfo(MongooseConnection conn, MongooseRequestInfo ri)
{
conn.write("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n");
conn.write("<html><body><head>Calling Info</head>");
conn.write("<p>Request: " + ri.request_method + "</p>");
conn.write("<p>URI: " + ri.uri + "</p>");
conn.write("<p>Query: " + ri.query_string + "</p>");
if (ri.post_data_len > 0) conn.write("<p>Post(" + ri.post_data_len + ")[@" + ri.post_data + "]: '" + Marshal.PtrToStringAnsi(ri.post_data) + "'</p>");
conn.write("<p>User:" + ri.remote_user + "</p>");
conn.write("<p>IP: " + ri.remote_ip + "</p>");
conn.write("<p>HTTP: " + ri.http_version + "</p>");
conn.write("<p>Port: " + ri.remote_port + "</p>");
conn.write("<p>NUM Headers: " + ri.num_headers + "</p>");
for (int i = 0; i < Math.Min(64, ri.num_headers); i++)
{
conn.write("<p>" + i + ":" + Marshal.PtrToStringAnsi(ri.http_headers[i].name)
+ ":" + Marshal.PtrToStringAnsi(ri.http_headers[i].value) + "</p>");
}
conn.write("</body></html>");
}
static void Main() {
Mongoose web_server = new Mongoose();
// Set options and /foo URI handler
web_server.set_option("ports", "8080");
web_server.set_option("root", "c:\\");
web_server.set_uri_callback("/foo", new MongooseCallback(UriHandler));
web_server.set_uri_callback("/dumpinfo", new MongooseCallback(UriDumpInfo));
// Serve requests until user presses "enter" on a keyboard
Console.ReadLine();
}
}
-134
View File
@@ -1,134 +0,0 @@
// Copyright (c) 2004-2009 Sergey Lyubka
//
// 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.
//
// $Id: mongoose.cs 472 2009-08-30 22:40:29Z spsone1 $
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)] public struct MongooseHeader {
public IntPtr name; // Using IntPtr here because if we use strings here,
public IntPtr value; // it won't be properly marshalled.
};
// This is "struct mg_request_info" from mongoose.h header file
[StructLayout(LayoutKind.Sequential)] public struct MongooseRequestInfo {
public string request_method;
public string uri;
public string http_version;
public string query_string;
public IntPtr post_data;
public string remote_user;
public int remote_ip; //int to match the 32bit declaration in c
public int remote_port;
public int post_data_len;
public int status_code;
public int num_headers;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=64)] public MongooseHeader[] http_headers;
};
// This is a delegate for mg_callback_t from mongoose.h header file
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void MongooseCallback2(IntPtr conn, ref MongooseRequestInfo ri, IntPtr user_data);
// This is a delegate to be used by the application
public delegate void MongooseCallback(MongooseConnection conn, MongooseRequestInfo ri);
public class Mongoose {
public string version;
private IntPtr ctx;
//These two events are here to store a ref to the callbacks while they are over in unmanaged code.
private event MongooseCallback2 delegates2;
private event MongooseCallback delegates1;
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern IntPtr mg_start();
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern void mg_stop(IntPtr ctx);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern string mg_version();
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern int mg_set_option(IntPtr ctx, string name, string value);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern string mg_get_option(IntPtr ctx, string name);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern void mg_set_uri_callback(IntPtr ctx, string uri_regex, MulticastDelegate func, IntPtr data);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern void mg_set_log_callback(IntPtr ctx, MulticastDelegate func);
public Mongoose() {
ctx = mg_start();
version = mg_version();
}
~Mongoose() {
mg_stop(this.ctx);
this.ctx = IntPtr.Zero;
}
public int set_option(string option_name, string option_value) {
return mg_set_option(this.ctx, option_name, option_value);
}
public string get_option(string option_name) {
return mg_get_option(this.ctx, option_name);
}
public void set_uri_callback(string uri_regex, MongooseCallback func) {
// Build a closure around user function. Initialize connection object there which wraps
// mg_write() and other useful methods, and then call user specified handler.
MongooseCallback2 callback = delegate(IntPtr conn, ref MongooseRequestInfo ri, IntPtr user_data) {
MongooseConnection connection = new MongooseConnection(conn, this);
func(connection, ri);
};
// store a reference to the callback so it won't be GC'ed while its over in unmanged code
delegates2 += callback;
mg_set_uri_callback(this.ctx, uri_regex, callback, IntPtr.Zero);
}
public void set_log_callback(MongooseCallback func) {
delegates1 += func;
mg_set_log_callback(this.ctx, func);
}
}
public class MongooseConnection {
public Mongoose mongoose;
private IntPtr conn;
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern string mg_get_header(IntPtr ctx, string name);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern string mg_get_var(IntPtr ctx, string name);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] private static extern void mg_free(IntPtr ptr);
[DllImport("_mongoose",CallingConvention=CallingConvention.Cdecl)] public static extern int mg_write(IntPtr conn, string data, int length);
public MongooseConnection(IntPtr conn_, Mongoose mongoose_) {
mongoose = mongoose_;
conn = conn_;
}
public string get_header(string header_name) {
return mg_get_header(this.conn, header_name);
}
public string get_var(string header_name) {
string s = mg_get_var(this.conn, header_name);
string copy = "" + s;
mg_free(Marshal.StringToHGlobalAnsi(s));
return copy;
}
public int write(string data) {
return mg_write(this.conn, data, data.Length);
}
}
-63
View File
@@ -1,63 +0,0 @@
# This is Python example on how to use Mongoose embeddable web server,
# http://code.google.com/p/mongoose
#
# Before using the mongoose module, make sure that Mongoose shared library is
# built and present in the current (or system library) directory
import mongoose
import sys
# Handle /show and /form URIs.
def EventHandler(event, conn):
info = conn.info
if event == mongoose.HTTP_ERROR:
conn.printf('%s', 'HTTP/1.0 200 OK\r\n')
conn.printf('%s', 'Content-Type: text/plain\r\n\r\n')
conn.printf('HTTP error: %d\n', info.status_code)
return True
elif event == mongoose.NEW_REQUEST and info.uri == '/show':
conn.printf('%s', 'HTTP/1.0 200 OK\r\n')
conn.printf('%s', 'Content-Type: text/plain\r\n\r\n')
conn.printf('%s %s\n', info.request_method, info.uri)
if info.request_method == 'POST':
content_len = conn.get_header('Content-Length')
post_data = conn.read(int(content_len))
my_var = conn.get_var(post_data, 'my_var')
else:
my_var = conn.get_var(info.query_string, 'my_var')
conn.printf('my_var: %s\n', my_var or '<not set>')
conn.printf('HEADERS: \n')
for header in info.http_headers[:info.num_headers]:
conn.printf(' %s: %s\n', header.name, header.value)
return True
elif event == mongoose.NEW_REQUEST and info.uri == '/form':
conn.write('HTTP/1.0 200 OK\r\n'
'Content-Type: text/html\r\n\r\n'
'Use GET: <a href="/show?my_var=hello">link</a>'
'<form action="/show" method="POST">'
'Use POST: type text and submit: '
'<input type="text" name="my_var"/>'
'<input type="submit"/>'
'</form>')
return True
elif event == mongoose.NEW_REQUEST and info.uri == '/secret':
conn.send_file('/etc/passwd')
return True
else:
return False
# Create mongoose object, and register '/foo' URI handler
# List of options may be specified in the contructor
server = mongoose.Mongoose(EventHandler,
document_root='/tmp',
listening_ports='8080')
print ('Mongoose started on port %s, press enter to quit'
% server.get_option('listening_ports'))
sys.stdin.read(1)
# Deleting server object stops all serving threads
print 'Stopping server.'
del server
-160
View File
@@ -1,160 +0,0 @@
# Copyright (c) 2004-2009 Sergey Lyubka
#
# 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.
#
# $Id: mongoose.py 471 2009-08-30 14:30:21Z valenok $
"""
This module provides python binding for the Mongoose web server.
There are two classes defined:
Connection: - wraps all functions that accept struct mg_connection pointer
as first argument.
Mongoose: wraps all functions that accept struct mg_context pointer as
first argument.
Creating Mongoose object automatically starts server, deleting object
automatically stops it. There is no need to call mg_start() or mg_stop().
"""
import ctypes
import os
NEW_REQUEST = 0
HTTP_ERROR = 1
EVENT_LOG = 2
INIT_SSL = 3
class mg_header(ctypes.Structure):
"""A wrapper for struct mg_header."""
_fields_ = [
('name', ctypes.c_char_p),
('value', ctypes.c_char_p),
]
class mg_request_info(ctypes.Structure):
"""A wrapper for struct mg_request_info."""
_fields_ = [
('user_data', ctypes.c_char_p),
('request_method', ctypes.c_char_p),
('uri', ctypes.c_char_p),
('http_version', ctypes.c_char_p),
('query_string', ctypes.c_char_p),
('remote_user', ctypes.c_char_p),
('log_message', ctypes.c_char_p),
('remote_ip', ctypes.c_long),
('remote_port', ctypes.c_int),
('status_code', ctypes.c_int),
('is_ssl', ctypes.c_int),
('num_headers', ctypes.c_int),
('http_headers', mg_header * 64),
]
mg_callback_t = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p)
class Connection(object):
"""A wrapper class for all functions that take
struct mg_connection * as the first argument."""
def __init__(self, mongoose, connection):
self.m = mongoose
self.conn = ctypes.c_void_p(connection)
self.info = self.m.dll.mg_get_request_info(self.conn).contents
def get_header(self, name):
val = self.m.dll.mg_get_header(self.conn, name)
return ctypes.c_char_p(val).value
def get_var(self, data, name):
size = data and len(data) or 0
buf = ctypes.create_string_buffer(size)
n = self.m.dll.mg_get_var(data, size, name, buf, size)
return n >= 0 and buf or None
def printf(self, fmt, *args):
val = self.m.dll.mg_printf(self.conn, fmt, *args)
return ctypes.c_int(val).value
def write(self, data):
val = self.m.dll.mg_write(self.conn, data, len(data))
return ctypes.c_int(val).value
def read(self, size):
buf = ctypes.create_string_buffer(size)
n = self.m.dll.mg_read(self.conn, buf, size)
return n <= 0 and None or buf[:n]
def send_file(self, path):
self.m.dll.mg_send_file(self.conn, path)
class Mongoose(object):
"""A wrapper class for Mongoose shared library."""
def __init__(self, callback, **kwargs):
if os.name == 'nt':
self.dll = ctypes.WinDLL('_mongoose.dll')
else:
self.dll = ctypes.CDLL('_mongoose.so')
self.dll.mg_start.restype = ctypes.c_void_p
self.dll.mg_modify_passwords_file.restype = ctypes.c_int
self.dll.mg_read.restype = ctypes.c_int
self.dll.mg_write.restype = ctypes.c_int
self.dll.mg_printf.restype = ctypes.c_int
self.dll.mg_get_header.restype = ctypes.c_char_p
self.dll.mg_get_var.restype = ctypes.c_int
self.dll.mg_get_cookie.restype = ctypes.c_int
self.dll.mg_get_option.restype = ctypes.c_char_p
self.dll.mg_get_request_info.restype = ctypes.POINTER(mg_request_info)
if callback:
# Create a closure that will be called by the shared library.
def func(event, connection):
# Wrap connection pointer into the connection
# object and call Python callback
conn = Connection(self, connection)
return callback(event, conn) and 1 or 0
# Convert the closure into C callable object
self.callback = mg_callback_t(func)
self.callback.restype = ctypes.c_char_p
else:
self.callback = ctypes.c_void_p(0)
args = [y for x in kwargs.items() for y in x] + [None]
options = (ctypes.c_char_p * len(args))(*args)
ret = self.dll.mg_start(self.callback, 0, options)
self.ctx = ctypes.c_void_p(ret)
def __del__(self):
"""Destructor, stop Mongoose instance."""
self.dll.mg_stop(self.ctx)
def get_option(self, name):
return self.dll.mg_get_option(self.ctx, name)
+1
View File
@@ -0,0 +1 @@
*.exe
+118
View File
@@ -0,0 +1,118 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of object file images to be generated ()
# GEN_BINS - list of binaries to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
TARGET = eagle
#FLAVOR = release
FLAVOR = debug
EXTRA_CCFLAGS += -Wall -Werror
ifndef PDIR # {
GEN_IMAGES= eagle.app.v6.out
GEN_BINS= eagle.app.v6.bin
SPECIAL_MKTARGETS=$(APP_MKTARGETS)
SUBDIRS=user
endif # } PDIR
LDDIR = $(SDK_PATH)/ld
CCFLAGS += -Os
TARGET_LDFLAGS = \
-nostdlib \
-Wl,-EL \
--longcalls \
--text-section-literals
ifeq ($(FLAVOR),debug)
TARGET_LDFLAGS += -g -O2
endif
ifeq ($(FLAVOR),release)
TARGET_LDFLAGS += -g -O0
endif
COMPONENTS_eagle.app.v6 = \
user/libuser.a
LINKFLAGS_eagle.app.v6 = \
-L$(SDK_PATH)/lib \
-Wl,--gc-sections \
-nostdlib \
-T$(LD_FILE) \
-Wl,--no-check-sections \
-u call_user_start \
-Wl,-static \
-Wl,--start-group \
-lcirom \
-lgcc \
-lhal \
-lphy \
-lpp \
-lnet80211 \
-lwpa \
-lcrypto \
-lmain \
-lfreertos \
-llwip \
$(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group
DEPENDS_eagle.app.v6 = \
$(LD_FILE) \
$(LDDIR)/eagle.rom.addr.v6.ld
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
#UNIVERSAL_TARGET_DEFINES = \
# Other potential configuration flags include:
# -DTXRX_TXBUF_DEBUG
# -DTXRX_RXBUF_DEBUG
# -DWLAN_CONFIG_CCX
CONFIGURATION_DEFINES = -DICACHE_FLASH
DEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)
DDEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \
$(CONFIGURATION_DEFINES)
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES := $(INCLUDES) -I $(PDIR)include
sinclude $(SDK_PATH)/Makefile
.PHONY: FORCE
FORCE:
+36
View File
@@ -0,0 +1,36 @@
This is a Mongoose "Hello, world" that can be compiled under ESP8266 RTOS SDK.
It sets up an AP (SSID `Mongoose`) and serves a "hello world" page on http://192.168.4.1/
Most of the the boilerplate comes from [project_template](https://github.com/espressif/ESP8266_RTOS_SDK/tree/master/examples/project_template) (@ [3ca6af5](https://github.com/espressif/ESP8266_RTOS_SDK/tree/3ca6af5da68678d809b34c7cd98bee71e0235039/examples/project_template)) with minimal changes.
To build with no changes to the SDK, you will need a module with 1MB (8Mb) flash or more.
Compile (for NodeMCU 1.0):
```
$ export SDK_PATH=/path/to/ESP8266_RTOS_SDK
$ export BIN_PATH=./bin
$ make clean; make BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=dio SPI_SIZE_MAP=6
```
Flash (using [esptool](https://github.com/themadinventor/esptool)):
```
$ esptool.py --port /dev/ttyUSB0 --baud 230400 \
write_flash --flash_mode=dio --flash_size=32m \
0x00000 ${SDK_PATH}/bin/boot_v1.4\(b1\).bin \
0x01000 ${BIN_PATH}/upgrade/user1.4096.new.6.bin
```
The output can be made to fit in 512KB (4Mb), but stock linker scripts do not reserve enough space for code.
Custom linker script is provided for that, so you can use it for smaller devices like so (example that will work with ESP-01):
```
$ make clean; make BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=qio SPI_SIZE_MAP=0 LD_FILE=ld/eagle.app.v6.512.compact.ld
$ esptool.py --port /dev/ttyUSB0 --baud 230400 \
write_flash --flash_mode=qio --flash_size=4m \
0x00000 ${BIN_PATH}/eagle.flash.bin \
0x10000 ${BIN_PATH}/eagle.irom0text.bin
```
+173
View File
@@ -0,0 +1,173 @@
#!/bin/bash
:<<!
******NOTICE******
MUST set SDK_PATH & BIN_PATH firstly!!!
example:
export SDK_PATH=~/ESP8266_RTOS_SDK
export BIN_PATH=~/esp8266_bin
!
echo "gen_misc.sh version 20150911"
echo ""
if [ $SDK_PATH ]; then
echo "SDK_PATH:"
echo "$SDK_PATH"
echo ""
else
echo "ERROR: Please export SDK_PATH in gen_misc.sh firstly, exit!!!"
exit
fi
if [ $BIN_PATH ]; then
echo "BIN_PATH:"
echo "$BIN_PATH"
echo ""
else
echo "ERROR: Please export BIN_PATH in gen_misc.sh firstly, exit!!!"
exit
fi
echo "Please check SDK_PATH & BIN_PATH, enter (Y/y) to continue:"
read input
if [[ $input != Y ]] && [[ $input != y ]]; then
exit
fi
echo ""
echo "Please follow below steps(1-5) to generate specific bin(s):"
echo "STEP 1: use boot_v1.2+ by default"
boot=new
echo "boot mode: $boot"
echo ""
echo "STEP 2: choose bin generate(0=eagle.flash.bin+eagle.irom0text.bin, 1=user1.bin, 2=user2.bin)"
echo "enter (0/1/2, default 0):"
read input
if [ -z "$input" ]; then
if [ $boot != none ]; then
boot=none
echo "ignore boot"
fi
app=0
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
elif [ $input == 1 ]; then
if [ $boot == none ]; then
app=0
echo "choose no boot before"
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
else
app=1
echo "generate bin: user1.bin"
fi
elif [ $input == 2 ]; then
if [ $boot == none ]; then
app=0
echo "choose no boot before"
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
else
app=2
echo "generate bin: user2.bin"
fi
else
if [ $boot != none ]; then
boot=none
echo "ignore boot"
fi
app=0
echo "generate bin: eagle.flash.bin+eagle.irom0text.bin"
fi
echo ""
echo "STEP 3: choose spi speed(0=20MHz, 1=26.7MHz, 2=40MHz, 3=80MHz)"
echo "enter (0/1/2/3, default 2):"
read input
if [ -z "$input" ]; then
spi_speed=40
elif [ $input == 0 ]; then
spi_speed=20
elif [ $input == 1 ]; then
spi_speed=26.7
elif [ $input == 3 ]; then
spi_speed=80
else
spi_speed=40
fi
echo "spi speed: $spi_speed MHz"
echo ""
echo "STEP 4: choose spi mode(0=QIO, 1=QOUT, 2=DIO, 3=DOUT)"
echo "enter (0/1/2/3, default 0):"
read input
if [ -z "$input" ]; then
spi_mode=QIO
elif [ $input == 1 ]; then
spi_mode=QOUT
elif [ $input == 2 ]; then
spi_mode=DIO
elif [ $input == 3 ]; then
spi_mode=DOUT
else
spi_mode=QIO
fi
echo "spi mode: $spi_mode"
echo ""
echo "STEP 5: choose spi size and map"
echo " 0= 512KB( 256KB+ 256KB)"
echo " 2=1024KB( 512KB+ 512KB)"
echo " 3=2048KB( 512KB+ 512KB)"
echo " 4=4096KB( 512KB+ 512KB)"
echo " 5=2048KB(1024KB+1024KB)"
echo " 6=4096KB(1024KB+1024KB)"
echo "enter (0/2/3/4/5/6, default 0):"
read input
if [ -z "$input" ]; then
spi_size_map=0
echo "spi size: 512KB"
echo "spi ota map: 256KB + 256KB"
elif [ $input == 2 ]; then
spi_size_map=2
echo "spi size: 1024KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 3 ]; then
spi_size_map=3
echo "spi size: 2048KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 4 ]; then
spi_size_map=4
echo "spi size: 4096KB"
echo "spi ota map: 512KB + 512KB"
elif [ $input == 5 ]; then
spi_size_map=5
echo "spi size: 2048KB"
echo "spi ota map: 1024KB + 1024KB"
elif [ $input == 6 ]; then
spi_size_map=6
echo "spi size: 4096KB"
echo "spi ota map: 1024KB + 1024KB"
else
spi_size_map=0
echo "spi size: 512KB"
echo "spi ota map: 256KB + 256KB"
fi
echo ""
echo "start..."
echo ""
make clean
make BOOT=$boot APP=$app SPI_SPEED=$spi_speed SPI_MODE=$spi_mode SPI_SIZE_MAP=$spi_size_map
@@ -0,0 +1,20 @@
/* eagle.flash.bin @ 0x00000 */
/* eagle.irom0text.bin @ 0x10000 */
/*
* Flash map for 512KB flash.
*
* There is 0x8000 (32KB) available between 0x8000 and 0x10000.
*
* Note: IROM images starts at 0x10000 (ignore Makefile output which says 0x40000.
*/
MEMORY
{
dport0_0_seg : org = 0x3FF00000, len = 0x10
dram0_0_seg : org = 0x3FFE8000, len = 0x18000
iram1_0_seg : org = 0x40100000, len = 0x8000
irom0_0_seg : org = 0x40210000, len = 0x6C000
}
INCLUDE "../ld/eagle.app.v6.common.ld"
+56
View File
@@ -0,0 +1,56 @@
This is a simple project template.
sample_lib is an example for multi-level folder Makefile, notice the folder structure and each Makefile, you can get the clue.
HOWTO:
1. Copy this folder to anywhere.
Example:
Copy to ~/workspace/project_template
You can rename this folder as you like.
2. Export SDK_PATH and BIN_PATH.
Example:
Your SDK path is ~/esp_iot_rtos_sdk, and want generate bin at ~/esp8266_bin.
Do follow steps:
1>. export SDK_PATH=~/esp_iot_rtos_sdk
2>. export BIN_PATH=~/esp8266_bin
SDK and project are seperate, you can update SDK without change your project.
3. Enter project_template folder, run ./gen_misc.sh, and follow the tips and steps.
Compile Options:
(1) COMPILE
Possible value: xcc
Default value:
If not set, use gcc by default.
(2) BOOT
Possible value: none/old/new
none: no need boot
old: use boot_v1.1
new: use boot_v1.2
Default value: new
(3) APP
Possible value: 0/1/2
0: original mode, generate eagle.app.v6.flash.bin and eagle.app.v6.irom0text.bin
1: generate user1
2: generate user2
Default value: 0
(3) SPI_SPEED
Possible value: 20/26.7/40/80
Default value: 40
(4) SPI_MODE
Possible value: QIO/QOUT/DIO/DOUT
Default value: QIO
(4) SPI_SIZE_MAP
Possible value: 0/2/3/4/5/6
Default value: 0
For example:
make COMPILE=gcc BOOT=new APP=1 SPI_SPEED=40 SPI_MODE=QIO SPI_SIZE_MAP=0
+47
View File
@@ -0,0 +1,47 @@
#############################################################
# Required variables for each makefile
# Discard this section from all parent makefiles
# Expected variables (with automatic defaults):
# CSRCS (all "C" files in the dir)
# SUBDIRS (all subdirs with a Makefile)
# GEN_LIBS - list of libs to be generated ()
# GEN_IMAGES - list of images to be generated ()
# COMPONENTS_xxx - a list of libs/objs in the form
# subdir/lib to be extracted and rolled up into
# a generated lib/image xxx.a ()
#
ifndef PDIR
GEN_LIBS = libuser.a
endif
#############################################################
# Configuration i.e. compile options etc.
# Target specific stuff (defines etc.) goes in here!
# Generally values applying to a tree are captured in the
# makefile at its root level - these are then overridden
# for a subtree within the makefile rooted therein
#
DEFINES += -DMG_DISABLE_DAV -DMG_DISABLE_SYNC_RESOLVER -DMG_DISABLE_CGI \
-DMG_DISABLE_SOCKETPAIR -DMG_DISABLE_DIRECTORY_LISTING \
-DMG_MAX_HTTP_HEADERS=20 -DMG_MAX_HTTP_REQUEST_SIZE=1024 \
-DMG_MAX_PATH=40 -DMG_MAX_HTTP_SEND_IOBUF=1024 \
-DMG_ESP8266 -DRTOS_SDK -DMG_LWIP
#############################################################
# Recursion Magic - Don't touch this!!
#
# Each subtree potentially has an include directory
# corresponding to the common APIs applicable to modules
# rooted at that subtree. Accordingly, the INCLUDE PATH
# of a module can only contain the include directories up
# its parent path, and not its siblings
#
# Required for each makefile to inherit from the parent
#
INCLUDES += -I ./
PDIR := ../$(PDIR)
sinclude $(PDIR)Makefile
+54
View File
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*/
#include <ctype.h>
#include <sys/time.h>
#include <stdint.h>
#include <math.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "esp_common.h"
/* Makes fprintf(stdout) and stderr work. */
_ssize_t _write_r(struct _reent *r, int fd, void *buf, size_t len) {
if (fd == 1 || fd == 2) {
size_t i;
for (i = 0; i < len; i++) {
os_putc(((char *) buf)[i]);
}
return len;
}
return -1;
}
/*
* You'll need to implement _open_r and friends if you want file operations. See
* https://github.com/cesanta/smart.js/blob/master/platforms/esp8266/user/esp_fs.c
* for SPIFFS-based implementation.
*/
void abort(void) __attribute__((no_instrument_function));
void abort(void) {
/* cause an unaligned access exception, that will drop you into gdb */
*(int *) 1 = 1;
while (1)
; /* avoid gcc warning because stdlib abort() has noreturn attribute */
}
void _exit(int status) {
printf("_exit(%d)\n", status);
abort();
}
int _gettimeofday_r(struct _reent *r, struct timeval *tp, void *tzp) {
uint32_t time = system_get_time();
tp->tv_sec = time / 1000000;
tp->tv_usec = time % 1000000;
return 0;
}
+1
View File
@@ -0,0 +1 @@
../../../mongoose.c
+1
View File
@@ -0,0 +1 @@
../../../mongoose.h
+108
View File
@@ -0,0 +1,108 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*/
#include "esp_common.h"
#include "mongoose.h"
#define AP_SSID "Mongoose"
#define AP_PASS "Mongoose"
#define AP_CHAN 9
#define MG_LISTEN_ADDR "80"
#define MG_TASK_STACK_SIZE 2048
#define MG_TASK_PRIORITY 1
void uart_div_modify(int uart_no, unsigned int freq);
void ev_handler(struct mg_connection *nc, int ev, void *p) {
static const char *reply_fmt =
"HTTP/1.0 200 OK\r\n"
"Connection: close\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"Hello %s\n";
LOG(LL_DEBUG, ("conn %p ev %d", nc, ev));
switch (ev) {
case MG_EV_ACCEPT: {
char addr[32];
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
LOG(LL_INFO, ("Connection %p from %s", nc, addr));
break;
}
case MG_EV_HTTP_REQUEST: {
char addr[32];
struct http_message *hm = (struct http_message *) p;
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
LOG(LL_INFO,
("HTTP request from %s: %.*s %.*s", addr, (int) hm->method.len,
hm->method.p, (int) hm->uri.len, hm->uri.p));
mg_printf(nc, reply_fmt, addr);
nc->flags |= MG_F_SEND_AND_CLOSE;
break;
}
case MG_EV_CLOSE: {
LOG(LL_INFO, ("Connection %p closed", nc));
break;
}
}
}
void setup_ap() {
struct softap_config cfg;
wifi_set_opmode_current(SOFTAP_MODE);
memset(&cfg, 0, sizeof(cfg));
strcpy((char *) cfg.ssid, AP_SSID);
strcpy((char *) cfg.password, AP_PASS);
cfg.ssid_len = strlen((const char *) cfg.ssid);
cfg.authmode =
strlen((const char *) cfg.password) ? AUTH_WPA2_PSK : AUTH_OPEN;
cfg.channel = AP_CHAN;
cfg.ssid_hidden = 0;
cfg.max_connection = 10;
cfg.beacon_interval = 100; /* ms */
LOG(LL_INFO, ("Setting up AP '%s' on channel %d", cfg.ssid, cfg.channel));
wifi_softap_set_config_current(&cfg);
}
static void mg_task(void *arg) {
struct mg_mgr mgr;
struct mg_connection *nc;
cs_log_set_level(LL_INFO);
LOG(LL_INFO, ("SDK version: %s", system_get_sdk_version()));
setup_ap();
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, MG_LISTEN_ADDR, ev_handler);
if (nc == NULL) {
LOG(LL_ERROR, ("Error setting up listener!"));
return;
}
mg_set_protocol_http_websocket(nc);
while (1) {
mg_mgr_poll(&mgr, 1000);
}
}
xTaskHandle s_mg_task_handle;
void user_init(void) {
uart_div_modify(0, UART_CLK_FREQ / 115200);
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
xTaskCreate(mg_task, (const signed char *) "mongoose", MG_TASK_STACK_SIZE,
NULL, MG_TASK_PRIORITY, &s_mg_task_handle);
}
+14 -6
View File
@@ -1,7 +1,15 @@
CFLAGS= -W -Wall -I.. -pthread -g # Copyright (c) 2014 Cesanta Software
# All rights reserved
all: SUBDIRS = $(sort $(dir $(wildcard */)))
OS=`uname`; \ X = $(SUBDIRS)
test "$$OS" = Linux && LIBS="-ldl" ; \
$(CC) $(CFLAGS) hello.c ../mongoose.c $$LIBS $(ADD) -o hello; .PHONY: $(SUBDIRS)
$(CC) $(CFLAGS) chat.c ../mongoose.c $$LIBS $(ADD) -o chat
all: $(SUBDIRS)
$(SUBDIRS):
@$(MAKE) -C $@
clean:
for d in $(SUBDIRS) ; do $(MAKE) -C $$d clean ; done
+25
View File
@@ -0,0 +1,25 @@
PROG = api_server
SOURCES = $(PROG).c sqlite3.c db_plugin_sqlite.c ../../mongoose.c
CFLAGS = -W -Wall -pthread $(CFLAGS_EXTRA)
ifeq ($(OS), Windows_NT)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
CFLAGS += -ldl -lm
endif
endif
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I.. /MD /Fe$@
test: $(PROG)
sh unit_test.sh $$(pwd)/$(PROG)
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+104
View File
@@ -0,0 +1,104 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
#include "db_plugin.h"
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static int s_sig_num = 0;
static void *s_db_handle = NULL;
static const char *s_db_path = "api_server.db";
static const struct mg_str s_get_method = MG_STR("GET");
static const struct mg_str s_put_method = MG_STR("PUT");
static const struct mg_str s_delele_method = MG_STR("DELETE");
static void signal_handler(int sig_num) {
signal(sig_num, signal_handler);
s_sig_num = sig_num;
}
static int has_prefix(const struct mg_str *uri, const struct mg_str *prefix) {
return uri->len > prefix->len && memcmp(uri->p, prefix->p, prefix->len) == 0;
}
static int is_equal(const struct mg_str *s1, const struct mg_str *s2) {
return s1->len == s2->len && memcmp(s1->p, s2->p, s2->len) == 0;
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
static const struct mg_str api_prefix = MG_STR("/api/v1");
struct http_message *hm = (struct http_message *) ev_data;
struct mg_str key;
switch (ev) {
case MG_EV_HTTP_REQUEST:
if (has_prefix(&hm->uri, &api_prefix)) {
key.p = hm->uri.p + api_prefix.len;
key.len = hm->uri.len - api_prefix.len;
if (is_equal(&hm->method, &s_get_method)) {
db_op(nc, hm, &key, s_db_handle, API_OP_GET);
} else if (is_equal(&hm->method, &s_put_method)) {
db_op(nc, hm, &key, s_db_handle, API_OP_SET);
} else if (is_equal(&hm->method, &s_delele_method)) {
db_op(nc, hm, &key, s_db_handle, API_OP_DEL);
} else {
mg_printf(nc, "%s",
"HTTP/1.0 501 Not Implemented\r\n"
"Content-Length: 0\r\n\r\n");
}
} else {
mg_serve_http(nc, hm, s_http_server_opts); /* Serve static content */
}
break;
default:
break;
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
struct mg_connection *nc;
int i;
/* Open listening socket */
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = "web_root";
/* Parse command line arguments */
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-D") == 0) {
mgr.hexdump_file = argv[++i];
} else if (strcmp(argv[i], "-f") == 0) {
s_db_path = argv[++i];
} else if (strcmp(argv[i], "-r") == 0) {
s_http_server_opts.document_root = argv[++i];
}
}
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
/* Open database */
if ((s_db_handle = db_open(s_db_path)) == NULL) {
fprintf(stderr, "Cannot open DB [%s]\n", s_db_path);
exit(EXIT_FAILURE);
}
/* Run event loop until signal is received */
printf("Starting RESTful server on port %s\n", s_http_port);
while (s_sig_num == 0) {
mg_mgr_poll(&mgr, 1000);
}
/* Cleanup */
mg_mgr_free(&mgr);
db_close(&s_db_handle);
printf("Exiting on signal %d\n", s_sig_num);
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
#ifndef DB_PLUGIN_HEADER_DEFINED
#define DB_PLUGIN_HEADER_DEFINED
#include "../../mongoose.h"
void *db_open(const char *db_path);
void db_close(void **db_handle);
enum { API_OP_GET, API_OP_SET, API_OP_DEL };
void db_op(struct mg_connection *nc, const struct http_message *hm,
const struct mg_str *key, void *db, int op);
#endif /* DB_PLUGIN_HEADER_DEFINED */
+107
View File
@@ -0,0 +1,107 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
#include "db_plugin.h"
#include "sqlite3.h"
void *db_open(const char *db_path) {
sqlite3 *db = NULL;
if (sqlite3_open_v2(db_path, &db, SQLITE_OPEN_READWRITE |
SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) == SQLITE_OK) {
sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS kv(key PRIMARY KEY, val);",
0, 0, 0);
}
return db;
}
void db_close(void **db_handle) {
if (db_handle != NULL && *db_handle != NULL) {
sqlite3_close(*db_handle);
*db_handle = NULL;
}
}
static void op_set(struct mg_connection *nc, const struct http_message *hm,
const struct mg_str *key, void *db) {
sqlite3_stmt *stmt = NULL;
char value[200];
const struct mg_str *body = hm->query_string.len > 0 ?
&hm->query_string : &hm->body;
mg_get_http_var(body, "value", value, sizeof(value));
if (sqlite3_prepare_v2(db, "INSERT OR REPLACE INTO kv VALUES (?, ?);",
-1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, key->p, key->len, SQLITE_STATIC);
sqlite3_bind_text(stmt, 2, value, strlen(value), SQLITE_STATIC);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
}
static void op_get(struct mg_connection *nc, const struct http_message *hm,
const struct mg_str *key, void *db) {
sqlite3_stmt *stmt = NULL;
const char *data = NULL;
int result;
(void) hm;
if (sqlite3_prepare_v2(db, "SELECT val FROM kv WHERE key = ?;",
-1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, key->p, key->len, SQLITE_STATIC);
result = sqlite3_step(stmt);
data = (char *) sqlite3_column_text(stmt, 0);
if ((result == SQLITE_OK || result == SQLITE_ROW) && data != NULL) {
mg_printf(nc, "HTTP/1.1 200 OK\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: %d\r\n\r\n%s",
(int) strlen(data), data);
} else {
mg_printf(nc, "%s", "HTTP/1.1 404 Not Found\r\n"
"Content-Length: 0\r\n\r\n");
}
sqlite3_finalize(stmt);
} else {
mg_printf(nc, "%s", "HTTP/1.1 500 Server Error\r\n"
"Content-Length: 0\r\n\r\n");
}
}
static void op_del(struct mg_connection *nc, const struct http_message *hm,
const struct mg_str *key, void *db) {
sqlite3_stmt *stmt = NULL;
int result;
(void) hm;
if (sqlite3_prepare_v2(db, "DELETE FROM kv WHERE key = ?;",
-1, &stmt, NULL) == SQLITE_OK) {
sqlite3_bind_text(stmt, 1, key->p, key->len, SQLITE_STATIC);
result = sqlite3_step(stmt);
if (result == SQLITE_OK || result == SQLITE_ROW) {
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
} else {
mg_printf(nc, "%s", "HTTP/1.1 404 Not Found\r\n"
"Content-Length: 0\r\n\r\n");
}
sqlite3_finalize(stmt);
} else {
mg_printf(nc, "%s", "HTTP/1.1 500 Server Error\r\n"
"Content-Length: 0\r\n\r\n");
}
}
void db_op(struct mg_connection *nc, const struct http_message *hm,
const struct mg_str *key, void *db, int op) {
switch (op) {
case API_OP_GET: op_get(nc, hm, key, db); break;
case API_OP_SET: op_set(nc, hm, key, db); break;
case API_OP_DEL: op_del(nc, hm, key, db); break;
default:
mg_printf(nc, "%s", "HTTP/1.0 501 Not Implemented\r\n"
"Content-Length: 0\r\n\r\n");
break;
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
PROG=$1
PORT=${2:-8000} # If second param is given, this is load balancer port
DB_FILE=/tmp/_$$.db
URL=http://127.0.0.1:$PORT/api/v1
cleanup() {
rm -rf $DB_FILE
kill -9 $PID >/dev/null 2>&1
}
#set -x
trap cleanup EXIT
cleanup
$PROG -f $DB_FILE &
PID=$!
#sleep 1
curl -s -X PUT -d 'value=123' $URL/foo
curl -s -X PUT -d 'value=success' $URL/bar/baz
# Fetch existing key
RESULT=$(curl -s $URL/bar/baz)
test "$RESULT" = "success" || exit 1
# Delete it
curl -s -X DELETE $URL/bar/baz
# Make sure it's deleted - GET must result in 404
RESULT=$(curl -s -i $URL/bar/baz | head -1 | tr -d '\r')
test "$RESULT" = "HTTP/1.1 404 Not Found" || exit 1
exit 0
+38
View File
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>RESTful API demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
* { outline: none; }
body {
background-color: #789; margin: 0;
padding: 0; font: 16px/1.4 Helvetica, Arial, sans-serif;
font: 16px/1.4 Helvetica, Arial, sans-serif;
}
div.content {
width: 800px; margin: 2em auto; padding: 20px 50px;
background-color: #fff; border-radius: 1em;
}
label { display: inline-block; min-width: 7em; }
input { border: 1px solid #ccc; padding: 0.2em; }
a:link, a:visited { color: #69c; text-decoration: none; }
@media (max-width: 700px) {
body { background-color: #fff; }
div.content { width: auto; margin: 0 auto; padding: 1em; }
}
</style>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script language="javascript" type="text/javascript">
jQuery(function() {
});
</script>
</head>
<body>
<div class="content">
<h1>API server</h1>
</div>
</body>
</html>
+2
View File
@@ -0,0 +1,2 @@
# This "makefile" is only intended to prevent errors during main makefile execution
all:
+46
View File
@@ -0,0 +1,46 @@
# Arduino Restful Client
This example demonstrates how to use [Mongoose](https://www.cesanta.com/mongoose) to send HTTP commands from Arduino.
Example sends free memory size and current board uptime, but it can be modified to send any user-specific data.
At the moment this example supports [Arduino Mega 2560](http://arduino.cc/en/Main/ArduinoBoardMega2560) board (and compatible) with either W5100-based
network shield (like [Arduino Ethernet Shield](http://arduino.cc/en/Main/ArduinoEthernetShield)) or [CC3000](http://www.ti.com/product/cc3000)-based WIFI Shield.
## Build and run instructions:
###To run with Arduino Ethernet (W5100) shield:
1. Add (Sketch->Add file...) the following files to sketch:
- /mongoose/mongoose.h
- /mongoose/mongoose.c
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
3. Buils and start (in console) /Users/alex/Projects/mongoose/examples/restful_server example
4. Make `board_ip` and `board_mac` variables suitable for your network and board
5. Change IP address in `s_target_address` variable to IP address of host running restful_server
6. Uncomment line `#include <Ethernet.h>`
7. Compile and flash sketch
8. restful_server will start to show current uptime and free memory size (with 5 seconds interval)
###To run with Adafruit WiFi (CC3000) shield:
1. Add (Sketch->Add files...) the following files to sketch:
- /mongoose/mongoose.h
- /mongoose/mongoose.c
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
2. Import Adafruit CC3000 library for mongoose
(select Sketch->Import Library...->Add library... and point
/mongoose/platforms/arduino_wifi_CC3000/adafruit_CC3000_lib_mongoose folder)
3. Buils and start (in console) /Users/alex/Projects/mongoose/examples/restful_server example
4. Make the following variables suitable for your network
- `board_ip`
- `subnet_mask`
- `gateway`
- `dns`
- `wlan_ssid`
- `wlan_pwd`
- `wlan_security`
5. Change IP address in `s_target_address` variable to IP address of host running restful_server
6. Uncomment line `#include <Adafruit_CC3000.h>`
8. Compile and flash sketch
9. restful_server will start to show current uptime and free memory size (with 5 seconds interval)
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*
* Build and run instructions:
* To run with Arduino Ethernet (W5100) shield:
* -----------------------------------------------------------
* 1. Add (Sketch->Add file...) the following files to sketch:
* - /mongoose/mongoose.h
* - /mongoose/mongoose.c
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
* 2. Buils and run in console /Users/alex/Projects/mongoose/examples/restful_server example
* 3. Make board_ip and board_mac variables suitable for your network and board
* 4. Uncomment line #include <Ethernet.h>
* 5. Change IP address in s_target_address variable to IP address of host running restful_server
* 6. Compile & flash sketch
* 7. restful_server server will start to show current uptime and free memory size (with 5 second interval)
*
* To run with Adafruit WiFi (CC3000) shield:
* -----------------------------------------------------------
* 1. Add (Sketch->Add files...) the following files to sketch:
* - /mongoose/mongoose.h
* - /mongoose/mongoose.c
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
* 2. Import Adafruit CC3000 library for mongoose (select Sketch->Import Library...->Add library... and point
* /mongoose/platforms/arduino_wifi_CC3000/adafruit_CC3000_lib_mongoose folder
* 3. Buils and run in console /Users/alex/Projects/mongoose/examples/restful_server example
* 4. Make the following variables suitable for your network
* - board_ip
* - subnet_mask
* - gateway
* - dns
* - wlan_ssid
* - wlan_pwd
* - wlan_security
* 5. Uncomment line #include <Adafruit_CC3000.h>
* 6. Compile & flash sketch
* 7. restful_server server will start to show current uptime and free memory size (with 5 second interval) *
*
*/
//#include <Ethernet.h>
//#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "mongoose.h"
// CHANGE THESE VARIABLES
// NB: Devices with the same address must not end up on the same network.
// Use MAC address provided by device manufacturer (e.g. on a sticker).
// If there isn't one, use a random one from the locally administered range.
// See http://en.wikipedia.org/wiki/MAC_address for details.
static uint8_t board_mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
static uint8_t board_ip[] = {192, 168, 10, 177};
#ifdef WIFI_CC3000
static uint8_t subnet_mask[] = {255, 255, 255, 0};
static uint8_t gateway[] = {192, 168, 10, 254};
static uint8_t dns_ip[] = {192, 168, 10, 254};
static const char *wlan_ssid = "mynetwork";
static const char *wlan_pwd = "mypassword";
static int wlan_security = WLAN_SEC_WPA2;
#endif
static const char *s_target_address = "192.168.10.3:8000";
/////////////////////////////////////////////
static const char *s_request = "/printcontent";
static uint32_t IP2U32(uint8_t* iparr) {
return ((uint32_t)iparr[0] << 24) | ((uint32_t)iparr[1] << 16) | (iparr[2] << 8) | (iparr[3]);
}
static int get_data_to_send(char* buf, int buf_size) {
// Adding data to send
// It could be any sensor data, now just put uptime & free memory size here
return snprintf(buf, buf_size, "Uptime: %lus Free memory: %db",
millis()/1000, get_freememsize());
}
static void rfc_ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
int connect_status;
switch (ev) {
case NS_CONNECT:
connect_status = * (int *) ev_data;
if (connect_status == 0) {
char buf[100];
int len = get_data_to_send(buf, sizeof(buf));
mg_printf(nc, "POST %s HTTP/1.0\r\nHost: %s\r\nContent-Lenght: %d"
"\r\n\r\n%s", s_request, s_target_address, len, buf);
nc->flags |= MG_F_SEND_AND_CLOSE;
} else {
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
break;
default:
break;
}
}
static struct mg_mgr mgr;
static struct mg_connection *nc;
void setup()
{
Serial.begin(9600);
Serial.println("Initialization...");
#if defined(ETHERNET_W5100)
avr_netinit(board_mac, board_ip);
#elif defined(WIFI_CC3000)
if (avr_netinit(wlan_ssid, wlan_pwd, wlan_security, IP2U32(board_ip),
IP2U32(subnet_mask), IP2U32(gateway), IP2U32(dns_ip)) != 0) {
Serial.println("Initialization error, check network settings");
return;
};
#endif
mg_mgr_init(&mgr, NULL);
Serial.println("Initialization done");
}
void loop() {
nc = mg_connect(&mgr, s_target_address, rfc_ev_handler);
if (nc != NULL) {
mg_set_protocol_http_websocket(nc);
}
uint32_t time_to_finish = millis() + 5000;
while (millis() < time_to_finish) {
mg_mgr_poll(&mgr, 1000);
}
}
+2
View File
@@ -0,0 +1,2 @@
# This "makefile" is only intended to prevent errors during main makefile execution
all:
+45
View File
@@ -0,0 +1,45 @@
# Arduino Restful Server
This example demonstrates how to use [Mongoose](https://www.cesanta.com/mongoose) to control Arduino
using HTTP requests.
Example just blinks by LED when Mongoose receives HTTP command, but it can be modified to execute any user-specific code.
At the moment this example supports [Arduino Mega 2560](http://arduino.cc/en/Main/ArduinoBoardMega2560) board (and compatible) with either W5100-based
network shield (like [Arduino Ethernet Shield](http://arduino.cc/en/Main/ArduinoEthernetShield)) or [CC3000](http://www.ti.com/product/cc3000)-based WIFI Shield.
## Build and run instructions:
###To run with Arduino Ethernet (W5100) shield:
1. Add (Sketch->Add file...) the following files to sketch:
- /mongoose/mongoose.h
- /mongoose/mongoose.c
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
2. Make `board_ip` and `board_mac` variables suitable for your network and board
3. Uncomment line `#include <Ethernet.h>`
4. Compile and flash sketch
5. Run `curl http://<board_ip/blink`
LED attached to PIN 13 will blink and board free memory size and board uptime will be displayed.
###To run with Adafruit WiFi (CC3000) shield:
1. Add (Sketch->Add files...) the following files to sketch:
- /mongoose/mongoose.h
- /mongoose/mongoose.c
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
- /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
2. Import Adafruit CC3000 library for mongoose
(select Sketch->Import Library...->Add library... and point
/mongoose/platforms/arduino_wifi_CC3000/adafruit_CC3000_lib_mongoose folder)
3. Make the following variables suitable for your network
- `board_ip`
- `subnet_mask`
- `gateway`
- `dns`
- `wlan_ssid`
- `wlan_pwd`
- `wlan_security`
5. Uncomment line `#include <Adafruit_CC3000.h>`
4. Compile and flash sketch
5. Run curl `http://<board_ip/blink`
LED attached to PIN 13 will blink and board free memory size and board uptime will be displayed.
@@ -0,0 +1,133 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*
* Build and run instructions:
* To run with Arduino Ethernet (W5100) shield:
* -----------------------------------------------------------
* 1. Add (Sketch->Add file...) the following files to sketch:
* - /mongoose/mongoose.h
* - /mongoose/mongoose.c
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
* 2. Make board_ip and board_mac variables suitable for your network and board
* 3. Uncomment line #include <Ethernet.h>
* 4. Compile & flash sketch
* 5. Run curl http://<board_ip/blink
* LED attached to PIN 13 will blink and board free memory size and uptime will responsed
*
* To run with Adafruit WiFi (CC3000) shield:
* -----------------------------------------------------------
* 1. Add (Sketch->Add files...) the following files to sketch:
* - /mongoose/mongoose.h
* - /mongoose/mongoose.c
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.h
* - /mongoose/platforms/arduino_ethernet_W5100/avrsupport.cpp
* 2. Import Adafruit CC3000 library for mongoose (select Sketch->Import Library...->Add library... and point
* /mongoose/platforms/arduino_wifi_CC3000/adafruit_CC3000_lib_mongoose folder
* 3. Make the following variables suitable for your network
* - board_ip
* - subnet_mask
* - gateway
* - dns
* - wlan_ssid
* - wlan_pwd
* - wlan_security
* 5. Uncomment line #include <Adafruit_CC3000.h>
* 4. Compile & flash sketch
* 5. Run curl http://<board_ip/blink
* LED attached to PIN 13 will blink and board free memory size and uptime will responsed
*
*/
//#include <Ethernet.h>
//#include <Adafruit_CC3000.h>
#include <SPI.h>
#include "mongoose.h"
// CHANGE THESE VARIABLES
// NB: Devices with the same address must not end up on the same network.
// Use MAC address provided by device manufacturer (e.g. on a sticker).
// If there isn't one, use a random one from the locally administered range.
// See http://en.wikipedia.org/wiki/MAC_address for details.
static uint8_t board_mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
static uint8_t board_ip[] = {192, 168, 10, 8};
#ifdef WIFI_CC3000
static uint8_t subnet_mask[] = {255, 255, 255, 0};
static uint8_t gateway[] = {192, 168, 10, 254};
static uint8_t dns_ip[] = {192, 168, 10, 254};
static const char *wlan_ssid = "mynetwork";
static const char *wlan_pwd = "mypassword";
static int wlan_security = WLAN_SEC_WPA2;
#endif
///////////////////////////////////////////////
static const char *s_http_port = "60000";
static uint32_t IP2U32(uint8_t* iparr) {
return ((uint32_t)iparr[0] << 24) | ((uint32_t)iparr[1] << 16) | (iparr[2] << 8) | (iparr[3]);
}
static void rfs_ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
char buf[100];
int clen;
switch (ev) {
case NS_HTTP_REQUEST:
if (mg_vcmp(&hm->uri, "/blink") == 0) {
blink(1, 500);
}
clen = snprintf(buf, sizeof(buf),
"Free memory size: %d Uptime: %d",
(int)get_freememsize(), (int)time(NULL));
mg_printf_http_chunk(nc, "HTTP/1.1 200 OK\r\n"
"Content-Length: %d\r\n"
"Transfer-Encoding: chunked\r\n\r\n"
"%s",
clen, buf);
mg_send_http_chunk(nc, "", 0);
break;
case NS_SEND:
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
break;
default:
break;
}
}
static struct mg_connection *nc;
static struct mg_mgr mgr;
void setup() {
Serial.begin(9600);
Serial.println("Initialization...");
#if defined(ETHERNET_W5100)
avr_netinit(board_mac, board_ip);
#elif defined(WIFI_CC3000)
if (avr_netinit(wlan_ssid, wlan_pwd, wlan_security, IP2U32(board_ip),
IP2U32(subnet_mask), IP2U32(gateway), IP2U32(dns_ip)) != 0) {
Serial.println("Initialization error, check network settings");
return;
};
#endif
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, rfs_ev_handler);
mg_set_protocol_http_websocket(nc);
Serial.println("Initialization done");
}
void loop() {
mg_mgr_poll(&mgr, 1000);
}
+2
View File
@@ -0,0 +1,2 @@
PROG = big_upload
include ../examples.mk
+153
View File
@@ -0,0 +1,153 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
//
// This example demonstrates how to handle very large requests without keeping
// them in memory.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mongoose.h"
static const char *s_http_port = "8000";
struct file_writer_data {
FILE *fp;
size_t bytes_left;
};
static void handle_request(struct mg_connection *nc) {
// This handler gets called only when we don't reset proto_handler in
// handle_recv, so we just return a page unconditionally.
mg_printf(nc, "%s",
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Connection: close\r\n"
"\r\n"
"<html><body>Upload example."
"<form method=\"POST\" action=\"/upload\" "
" enctype=\"multipart/form-data\">"
"<input type=\"file\" name=\"file\" /> <br/>"
"<input type=\"submit\" value=\"Upload\" />"
"</form></body></html>");
nc->flags |= MG_F_SEND_AND_CLOSE;
}
static void handle_recv(struct mg_connection *nc) {
struct file_writer_data *data = (struct file_writer_data *) nc->user_data;
if (data == NULL) {
// This is a new connection, try to parse HTTP request.
struct http_message hm;
int req_len = mg_parse_http(nc->recv_mbuf.buf, nc->recv_mbuf.len, &hm,
1 /* is_req */);
if (req_len < 0 ||
(req_len == 0 && nc->recv_mbuf.len >= MG_MAX_HTTP_REQUEST_SIZE)) {
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
} else if (req_len == 0) {
// Request is not complete yet, do nothing.
} else if (mg_vcasecmp(&hm.method, "POST") == 0 &&
mg_vcmp(&hm.uri, "/upload") == 0) {
// This is the request that we don't want to buffer in memory.
if (hm.body.len == (size_t) ~0 || hm.body.len == 0) {
mg_printf(nc, "%s",
"HTTP/1.1 411 Content-Length required\r\n"
"Content-Length: 0\r\n\r\n");
nc->flags |= MG_F_SEND_AND_CLOSE;
return;
}
// Reset proto_handler so Mongoose's http_handler() won't get confused
// once we start removing data from the buffer.
nc->proto_handler = NULL;
// Headers will be inaccessible later, so put everything we need into
// user_data.
data = calloc(1, sizeof(struct file_writer_data));
data->bytes_left = hm.body.len;
data->fp = tmpfile();
if (data->fp == NULL) {
mg_printf(nc, "%s",
"HTTP/1.1 500 Failed to open a file\r\n"
"Content-Length: 0\r\n\r\n");
nc->flags |= MG_F_SEND_AND_CLOSE;
return;
}
nc->user_data = (void *) data;
// Remove the headers from the buffer.
mbuf_remove(&nc->recv_mbuf, hm.body.p - nc->recv_mbuf.buf);
// Invoke itself again to write the piece of the body that is already in
// the buffer.
handle_recv(nc);
}
} else { // data != NULL
size_t to_write = data->bytes_left, written = 0;
if (nc->recv_mbuf.len < to_write) to_write = nc->recv_mbuf.len;
written = fwrite(nc->recv_mbuf.buf, 1, to_write, data->fp);
mbuf_remove(&nc->recv_mbuf, written);
data->bytes_left -= written;
if (data->bytes_left <= 0) {
// Request is complete, do something meaningful here.
mg_printf(nc,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/plain\r\n"
"Connection: close\r\n\r\n"
"Written %ld of POST data to a temp file\n\n",
(long) ftell(data->fp));
nc->flags |= MG_F_SEND_AND_CLOSE;
// handle_close will free the resources.
}
}
}
// Make sure we free all allocated resources
static void handle_close(struct mg_connection *nc) {
struct file_writer_data *data = (struct file_writer_data *) nc->user_data;
if (data != NULL) {
fclose(data->fp);
free(data);
nc->user_data = NULL;
}
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
(void) ev_data;
switch (ev) {
case MG_EV_HTTP_REQUEST:
// Invoked when the full HTTP request is in the buffer (including body).
handle_request(nc);
break;
case MG_EV_RECV:
// Invoked every time new data arrives.
handle_recv(nc);
break;
case MG_EV_CLOSE:
handle_close(nc);
break;
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
// Set up HTTP server parameters
mg_set_protocol_http_websocket(nc);
printf("Starting web server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
+4
View File
@@ -0,0 +1,4 @@
PROG = captive_dns_server
MODULE_CFLAGS=-DMG_ENABLE_DNS_SERVER
include ../rules.mk
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
/*
* Try it out with:
* $ dig -t A www.google.com -4 @localhost -p 5533
*/
#include "../../mongoose.h"
#include <stdio.h>
static int s_exit_flag = 0;
static in_addr_t s_our_ip_addr;
static const char *s_listening_addr = "udp://:5533";
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct mg_dns_message *msg;
struct mg_dns_resource_record *rr;
struct mg_dns_reply reply;
int i;
switch (ev) {
case MG_DNS_MESSAGE:
msg = (struct mg_dns_message *) ev_data;
reply = mg_dns_create_reply(&nc->send_mbuf, msg);
for (i = 0; i < msg->num_questions; i++) {
rr = &msg->questions[i];
if (rr->rtype == MG_DNS_A_RECORD) {
mg_dns_reply_record(&reply, rr, NULL, rr->rtype, 3600,
&s_our_ip_addr, 4);
}
}
/*
* We don't set the error flag even if there were no answers
* maching the MG_DNS_A_RECORD query type.
* This indicates that we have (syntetic) answers for MG_DNS_A_RECORD.
* See http://goo.gl/QWvufr for a distinction between NXDOMAIN and NODATA.
*/
mg_dns_send_reply(nc, &reply);
nc->flags |= MG_F_SEND_AND_CLOSE;
break;
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
struct mg_connection *nc;
int i;
mg_mgr_init(&mgr, NULL);
s_our_ip_addr = inet_addr("127.0.0.1");
/* Parse command line arguments */
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-D") == 0) {
mgr.hexdump_file = argv[++i];
} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
s_listening_addr = argv[++i];
} else {
s_our_ip_addr = inet_addr(argv[i]);
}
}
fprintf(stderr, "Listening on '%s'\n", s_listening_addr);
if ((nc = mg_bind(&mgr, s_listening_addr, ev_handler)) == NULL) {
fprintf(stderr, "cannot bind to socket\n");
exit(1);
}
mg_set_protocol_dns(nc);
while (s_exit_flag == 0) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
-385
View File
@@ -1,385 +0,0 @@
// This file is part of the Mongoose project, http://code.google.com/p/mongoose
// It implements an online chat server. For more details,
// see the documentation on the project web site.
// To test the application,
// 1. type "make" in the directory where this file lives
// 2. point your browser to http://127.0.0.1:8081
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <pthread.h>
#include "mongoose.h"
#define MAX_USER_LEN 20
#define MAX_MESSAGE_LEN 100
#define MAX_MESSAGES 5
#define MAX_SESSIONS 2
#define SESSION_TTL 120
static const char *authorize_url = "/authorize";
static const char *login_url = "/login.html";
static const char *ajax_reply_start =
"HTTP/1.1 200 OK\r\n"
"Cache: no-cache\r\n"
"Content-Type: application/x-javascript\r\n"
"\r\n";
// Describes single message sent to a chat. If user is empty (0 length),
// the message is then originated from the server itself.
struct message {
long id; // Message ID
char user[MAX_USER_LEN]; // User that have sent the message
char text[MAX_MESSAGE_LEN]; // Message text
time_t timestamp; // Message timestamp, UTC
};
// Describes web session.
struct session {
char session_id[33]; // Session ID, must be unique
char random[20]; // Random data used for extra user validation
char user[MAX_USER_LEN]; // Authenticated user
time_t expire; // Expiration timestamp, UTC
};
static struct message messages[MAX_MESSAGES]; // Ringbuffer for messages
static struct session sessions[MAX_SESSIONS]; // Current sessions
static long last_message_id;
// Protects messages, sessions, last_message_id
static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
// Get session object for the connection. Caller must hold the lock.
static struct session *get_session(const struct mg_connection *conn) {
int i;
char session_id[33];
time_t now = time(NULL);
mg_get_cookie(conn, "session", session_id, sizeof(session_id));
for (i = 0; i < MAX_SESSIONS; i++) {
if (sessions[i].expire != 0 &&
sessions[i].expire > now &&
strcmp(sessions[i].session_id, session_id) == 0) {
break;
}
}
return i == MAX_SESSIONS ? NULL : &sessions[i];
}
static void get_qsvar(const struct mg_request_info *request_info,
const char *name, char *dst, size_t dst_len) {
const char *qs = request_info->query_string;
mg_get_var(qs, strlen(qs == NULL ? "" : qs), name, dst, dst_len);
}
// Get a get of messages with IDs greater than last_id and transform them
// into a JSON string. Return that string to the caller. The string is
// dynamically allocated, caller must free it. If there are no messages,
// NULL is returned.
static char *messages_to_json(long last_id) {
const struct message *message;
int max_msgs, len;
char buf[sizeof(messages)]; // Large enough to hold all messages
// Read-lock the ringbuffer. Loop over all messages, making a JSON string.
pthread_rwlock_rdlock(&rwlock);
len = 0;
max_msgs = sizeof(messages) / sizeof(messages[0]);
// If client is too far behind, return all messages.
if (last_message_id - last_id > max_msgs) {
last_id = last_message_id - max_msgs;
}
for (; last_id < last_message_id; last_id++) {
message = &messages[last_id % max_msgs];
if (message->timestamp == 0) {
break;
}
// buf is allocated on stack and hopefully is large enough to hold all
// messages (it may be too small if the ringbuffer is full and all
// messages are large. in this case asserts will trigger).
len += snprintf(buf + len, sizeof(buf) - len,
"{user: '%s', text: '%s', timestamp: %lu, id: %lu},",
message->user, message->text, message->timestamp, message->id);
assert(len > 0);
assert((size_t) len < sizeof(buf));
}
pthread_rwlock_unlock(&rwlock);
return len == 0 ? NULL : strdup(buf);
}
// If "callback" param is present in query string, this is JSONP call.
// Return 1 in this case, or 0 if "callback" is not specified.
// Wrap an output in Javascript function call.
static int handle_jsonp(struct mg_connection *conn,
const struct mg_request_info *request_info) {
char cb[64];
get_qsvar(request_info, "callback", cb, sizeof(cb));
if (cb[0] != '\0') {
mg_printf(conn, "%s(", cb);
}
return cb[0] == '\0' ? 0 : 1;
}
// A handler for the /ajax/get_messages endpoint.
// Return a list of messages with ID greater than requested.
static void ajax_get_messages(struct mg_connection *conn,
const struct mg_request_info *request_info) {
char last_id[32], *json;
int is_jsonp;
mg_printf(conn, "%s", ajax_reply_start);
is_jsonp = handle_jsonp(conn, request_info);
get_qsvar(request_info, "last_id", last_id, sizeof(last_id));
if ((json = messages_to_json(strtoul(last_id, NULL, 10))) != NULL) {
mg_printf(conn, "[%s]", json);
free(json);
}
if (is_jsonp) {
mg_printf(conn, "%s", ")");
}
}
// Allocate new message. Caller must hold the lock.
static struct message *new_message(void) {
static int size = sizeof(messages) / sizeof(messages[0]);
struct message *message = &messages[last_message_id % size];
message->id = last_message_id++;
message->timestamp = time(0);
return message;
}
static void my_strlcpy(char *dst, const char *src, size_t len) {
strncpy(dst, src, len);
dst[len - 1] = '\0';
}
// A handler for the /ajax/send_message endpoint.
static void ajax_send_message(struct mg_connection *conn,
const struct mg_request_info *request_info) {
struct message *message;
struct session *session;
char text[sizeof(message->text) - 1];
int is_jsonp;
mg_printf(conn, "%s", ajax_reply_start);
is_jsonp = handle_jsonp(conn, request_info);
get_qsvar(request_info, "text", text, sizeof(text));
if (text[0] != '\0') {
// We have a message to store. Write-lock the ringbuffer,
// grab the next message and copy data into it.
pthread_rwlock_wrlock(&rwlock);
message = new_message();
// TODO(lsm): JSON-encode all text strings
session = get_session(conn);
assert(session != NULL);
my_strlcpy(message->text, text, sizeof(text));
my_strlcpy(message->user, session->user, sizeof(message->user));
pthread_rwlock_unlock(&rwlock);
}
mg_printf(conn, "%s", text[0] == '\0' ? "false" : "true");
if (is_jsonp) {
mg_printf(conn, "%s", ")");
}
}
// Redirect user to the login form. In the cookie, store the original URL
// we came from, so that after the authorization we could redirect back.
static void redirect_to_login(struct mg_connection *conn,
const struct mg_request_info *request_info) {
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Set-Cookie: original_url=%s\r\n"
"Location: %s\r\n\r\n",
request_info->uri, login_url);
}
// Return 1 if username/password is allowed, 0 otherwise.
static int check_password(const char *user, const char *password) {
// In production environment we should ask an authentication system
// to authenticate the user.
// Here however we do trivial check that user and password are not empty
return (user[0] && password[0]);
}
// Allocate new session object
static struct session *new_session(void) {
int i;
time_t now = time(NULL);
pthread_rwlock_wrlock(&rwlock);
for (i = 0; i < MAX_SESSIONS; i++) {
if (sessions[i].expire == 0 || sessions[i].expire < now) {
sessions[i].expire = time(0) + SESSION_TTL;
break;
}
}
pthread_rwlock_unlock(&rwlock);
return i == MAX_SESSIONS ? NULL : &sessions[i];
}
// Generate session ID. buf must be 33 bytes in size.
// Note that it is easy to steal session cookies by sniffing traffic.
// This is why all communication must be SSL-ed.
static void generate_session_id(char *buf, const char *random,
const char *user) {
mg_md5(buf, random, user, NULL);
}
static void send_server_message(const char *fmt, ...) {
va_list ap;
struct message *message;
pthread_rwlock_wrlock(&rwlock);
message = new_message();
message->user[0] = '\0'; // Empty user indicates server message
va_start(ap, fmt);
vsnprintf(message->text, sizeof(message->text), fmt, ap);
va_end(ap);
pthread_rwlock_unlock(&rwlock);
}
// A handler for the /authorize endpoint.
// Login page form sends user name and password to this endpoint.
static void authorize(struct mg_connection *conn,
const struct mg_request_info *request_info) {
char user[MAX_USER_LEN], password[MAX_USER_LEN];
struct session *session;
// Fetch user name and password.
get_qsvar(request_info, "user", user, sizeof(user));
get_qsvar(request_info, "password", password, sizeof(password));
if (check_password(user, password) && (session = new_session()) != NULL) {
// Authentication success:
// 1. create new session
// 2. set session ID token in the cookie
// 3. remove original_url from the cookie - not needed anymore
// 4. redirect client back to the original URL
//
// The most secure way is to stay HTTPS all the time. However, just to
// show the technique, we redirect to HTTP after the successful
// authentication. The danger of doing this is that session cookie can
// be stolen and an attacker may impersonate the user.
// Secure application must use HTTPS all the time.
my_strlcpy(session->user, user, sizeof(session->user));
snprintf(session->random, sizeof(session->random), "%d", rand());
generate_session_id(session->session_id, session->random, session->user);
send_server_message("<%s> joined", session->user);
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Set-Cookie: session=%s; max-age=3600; http-only\r\n" // Session ID
"Set-Cookie: user=%s\r\n" // Set user, needed by Javascript code
"Set-Cookie: original_url=/; max-age=0\r\n" // Delete original_url
"Location: /\r\n\r\n",
session->session_id, session->user);
} else {
// Authentication failure, redirect to login.
redirect_to_login(conn, request_info);
}
}
// Return 1 if request is authorized, 0 otherwise.
static int is_authorized(const struct mg_connection *conn,
const struct mg_request_info *request_info) {
struct session *session;
char valid_id[33];
int authorized = 0;
// Always authorize accesses to login page and to authorize URI
if (!strcmp(request_info->uri, login_url) ||
!strcmp(request_info->uri, authorize_url)) {
return 1;
}
pthread_rwlock_rdlock(&rwlock);
if ((session = get_session(conn)) != NULL) {
generate_session_id(valid_id, session->random, session->user);
if (strcmp(valid_id, session->session_id) == 0) {
session->expire = time(0) + SESSION_TTL;
authorized = 1;
}
}
pthread_rwlock_unlock(&rwlock);
return authorized;
}
static void redirect_to_ssl(struct mg_connection *conn,
const struct mg_request_info *request_info) {
const char *p, *host = mg_get_header(conn, "Host");
if (host != NULL && (p = strchr(host, ':')) != NULL) {
mg_printf(conn, "HTTP/1.1 302 Found\r\n"
"Location: https://%.*s:8082/%s:8082\r\n\r\n",
(int) (p - host), host, request_info->uri);
} else {
mg_printf(conn, "%s", "HTTP/1.1 500 Error\r\n\r\nHost: header is not set");
}
}
static void *event_handler(enum mg_event event,
struct mg_connection *conn) {
const struct mg_request_info *request_info = mg_get_request_info(conn);
void *processed = "yes";
if (event == MG_NEW_REQUEST) {
if (!request_info->is_ssl) {
redirect_to_ssl(conn, request_info);
} else if (!is_authorized(conn, request_info)) {
redirect_to_login(conn, request_info);
} else if (strcmp(request_info->uri, authorize_url) == 0) {
authorize(conn, request_info);
} else if (strcmp(request_info->uri, "/ajax/get_messages") == 0) {
ajax_get_messages(conn, request_info);
} else if (strcmp(request_info->uri, "/ajax/send_message") == 0) {
ajax_send_message(conn, request_info);
} else {
// No suitable handler found, mark as not processed. Mongoose will
// try to serve the request.
processed = NULL;
}
} else {
processed = NULL;
}
return processed;
}
static const char *options[] = {
"document_root", "html",
"listening_ports", "8081,8082s",
"ssl_certificate", "ssl_cert.pem",
"num_threads", "5",
NULL
};
int main(void) {
struct mg_context *ctx;
// Initialize random number generator. It will be used later on for
// the session identifier creation.
srand((unsigned) time(0));
// Setup and start Mongoose
ctx = mg_start(&event_handler, NULL, options);
assert(ctx != NULL);
// Wait until enter is pressed, then exit
printf("Chat server started on ports %s, press enter to quit.\n",
mg_get_option(ctx, "listening_ports"));
getchar();
mg_stop(ctx);
printf("%s\n", "Chat server stopped.");
return EXIT_SUCCESS;
}
// vim:ts=2:sw=2:et
+14
View File
@@ -0,0 +1,14 @@
PROG = coap_client
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. $(CFLAGS_EXTRA) -DMG_ENABLE_COAP
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+71
View File
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*
* This program sends CoAP CON-message to server (coap.me by default)
* and waits for answer.
*/
#include "mongoose.h"
static int s_time_to_exit = 0;
static char *s_default_address = "udp://coap.me:5683";
static void coap_handler(struct mg_connection *nc, int ev, void *p) {
switch (ev) {
case MG_EV_CONNECT: {
struct mg_coap_message cm;
uint32_t res;
memset(&cm, 0, sizeof(cm));
cm.msg_id = 1;
cm.msg_type = MG_COAP_MSG_CON;
printf("Sending CON...\n");
res = mg_coap_send_message(nc, &cm);
if (res == 0) {
printf("Sent CON with msg_id = %d\n", cm.msg_id);
} else {
printf("Error: %d\n", res);
s_time_to_exit = 1;
}
break;
}
case MG_EV_COAP_ACK:
case MG_EV_COAP_RST: {
struct mg_coap_message *cm = (struct mg_coap_message *) p;
printf("ACK/RST for message with msg_id = %d received\n", cm->msg_id);
s_time_to_exit = 1;
break;
}
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
struct mg_connection *nc;
char *address = s_default_address;
if (argc > 1) {
address = argv[1];
}
printf("Using %s as CoAP server\n", address);
mg_mgr_init(&mgr, 0);
nc = mg_connect(&mgr, address, coap_handler);
if (nc == NULL) {
printf("Unable to connect to %s\n", address);
return -1;
}
mg_set_protocol_coap(nc);
while (!s_time_to_exit) {
mg_mgr_poll(&mgr, 1000000);
}
mg_mgr_free(&mgr);
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
PROG = coap_server
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. $(CFLAGS_EXTRA) -DMG_ENABLE_COAP
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2015 Cesanta Software Limited
* All rights reserved
*
* This program listens on 5683 for CoAP messages,
* sends ACK is nessesary and dump everything received.
* It is possible to use ../coap_client to send message.
*/
#include "mongoose.h"
static char *s_default_address = "udp://:5683";
static int s_sig_received = 0;
static void signal_handler(int sig_num) {
signal(sig_num, signal_handler);
s_sig_received = sig_num;
}
static void coap_handler(struct mg_connection *nc, int ev, void *p) {
switch (ev) {
case MG_EV_COAP_CON: {
uint32_t res;
struct mg_coap_message *cm = (struct mg_coap_message *) p;
printf("CON with msg_id = %d received\n", cm->msg_id);
res = mg_coap_send_ack(nc, cm->msg_id);
if (res == 0) {
printf("Successfully sent ACK for message with msg_id = %d\n",
cm->msg_id);
} else {
printf("Error: %d\n", res);
}
break;
}
case MG_EV_COAP_NOC:
case MG_EV_COAP_ACK:
case MG_EV_COAP_RST: {
struct mg_coap_message *cm = (struct mg_coap_message *) p;
printf("ACK/RST/NOC with msg_id = %d received\n", cm->msg_id);
break;
}
}
}
int main() {
struct mg_mgr mgr;
struct mg_connection *nc;
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
mg_mgr_init(&mgr, 0);
nc = mg_bind(&mgr, s_default_address, coap_handler);
if (nc == NULL) {
printf("Unable to start listener at %s\n", s_default_address);
return -1;
}
printf("Listening for CoAP messages at %s\n", s_default_address);
mg_set_protocol_coap(nc);
while (!s_sig_received) {
mg_mgr_poll(&mgr, 1000000);
}
printf("Exiting on signal %d\n", s_sig_received);
mg_mgr_free(&mgr);
return 0;
}
+2
View File
@@ -0,0 +1,2 @@
PROG = server
include ../examples.mk
+43
View File
@@ -0,0 +1,43 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
#include "mongoose.h"
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
if (ev == MG_EV_HTTP_REQUEST) {
mg_serve_http(nc, p, s_http_server_opts); // Serves static content
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
cs_stat_t st;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
if (nc == NULL) {
fprintf(stderr, "Cannot bind to %s\n", s_http_port);
exit(1);
}
// Set up HTTP server parameters
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = "web_root"; // Set up web root directory
if (mg_stat(s_http_server_opts.document_root, &st) != 0) {
fprintf(stderr, "%s", "Cannot find web_root directory, exiting\n");
exit(1);
}
printf("Starting web server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Connected device demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="content">
<img src="logo.png" style="float:right; height: 50px; border-radius: 3px;">
<h1>Connected device demo - static content only</h1>
<p>
This page shows initial steps on how to make a device connected.
Mongoose serves static content from the <code>web_root</code>
directory. Images, CSS, HTML, JavaScript files could be dropped into the
<code>web_root</code> directory - and they'll be served happily
by Mongoose.
</p>
<p>
Below is a placeholder for the
settings section, and a real-time dashboard, which will be
implemented in the following examples.
Both settings section, and a dashboard section, could be organised
differently on this UI - for example, in different tabs. But, to
make the demonstration clearer, we show everything on one page.
</p>
<h1>Settings section</h1>
<p>Nothing here yet</p>
<h1>Dashboard section</h1>
<p>Nothing here yet</p>
</div>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -0,0 +1,31 @@
* {
outline: none;
}
body {
background-color: #36c;
margin: 0;
padding: 0;
font: 16px/1.4 Helvetica, Arial, sans-serif;
}
div.content {
width: 800px;
margin: 1em auto;
padding: 2em;
background-color: #fff;
border-radius: 1em;
}
code {
background: #f0f0f0;
padding: 0 0.3em;
color: #396;
border-radius: 0.3em;
}
a:link, a:visited {
color: #69c;
text-decoration: none;
}
+2
View File
@@ -0,0 +1,2 @@
PROG = server
include ../examples.mk
+81
View File
@@ -0,0 +1,81 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
#include "mongoose.h"
struct device_settings {
char setting1[100];
char setting2[100];
};
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static struct device_settings s_settings = { "value1", "value2" };
static void handle_save(struct mg_connection *nc, struct http_message *hm) {
// Get form variables and store settings values
mg_get_http_var(&hm->body, "setting1", s_settings.setting1,
sizeof(s_settings.setting1));
mg_get_http_var(&hm->body, "setting2", s_settings.setting2,
sizeof(s_settings.setting2));
// Send response
mg_printf(nc, "%s", "HTTP/1.1 302 OK\r\nLocation: /\r\n\r\n");
}
static void handle_ssi_call(struct mg_connection *nc, const char *param) {
if (strcmp(param, "setting1") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting1);
} else if (strcmp(param, "setting2") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting2);
}
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_HTTP_REQUEST:
if (mg_vcmp(&hm->uri, "/save") == 0) {
handle_save(nc, hm);
} else {
mg_serve_http(nc, hm, s_http_server_opts); // Serve static content
}
break;
case MG_EV_SSI_CALL:
handle_ssi_call(nc, ev_data);
break;
default:
break;
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
cs_stat_t st;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
if (nc == NULL) {
fprintf(stderr, "Cannot bind to %s\n", s_http_port);
exit(1);
}
// Set up HTTP server parameters
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = "web_root"; // Set up web root directory
if (mg_stat(s_http_server_opts.document_root, &st) != 0) {
fprintf(stderr, "%s", "Cannot find web_root directory, exiting\n");
exit(1);
}
printf("Starting web server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Connected device demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="content">
<img src="logo.png" style="float:right; height: 50px; border-radius: 3px;">
<h1>Connected device demo - settings section</h1>
<p>
This page is one of the series of examples that show how to make
devices connected with Mongoose. Here, we create a settings section
that expose some internal device variables, and allow user to change
them. They could be some stored in a database, in a file, or in
firmware RAM. In this example, we store them in RAM, and use two
variables, one integer and one string. We use SSI
<code>&lt;!--#call parameter_name --&gt;</code> directive to fetch
variable values from Mongoose.
</p>
<h1>Settings section</h1>
<form method="POST" action="/save">
<fieldset>
<legend>Device settings</legend>
<label>Setting 1:</label> <input type="text"
name="setting1" value="<!--#call setting1 -->" >
<label>Setting 2:</label> <input type="text"
name="setting2" value="<!--#call setting2 -->" >
<div>
<button type="submit">Save Settings</button>
</div>
</fieldset>
</form>
<h1>Dashboard section</h1>
<p>Nothing here yet</p>
</div>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -0,0 +1,67 @@
* {
outline: none;
}
body {
background: #36c;
color: #555;
margin: 0;
padding: 0;
font: 16px/1.4 Helvetica, Arial, sans-serif;
}
div.content {
width: 800px;
margin: 1em auto;
padding: 2em;
background-color: #fff;
border-radius: 1em;
}
fieldset {
border: 1px solid #ccc;
padding: 1em;
}
fieldset legend {
font-style: italic;
color: silver;
}
fieldset label {
text-align: right;
padding: 0 1em;
}
input[type=text] {
font-size: 100%;
padding: 0.2em;
border: 1px solid #ccc;
}
button {
color: #666;
background: #eee;
border: 1px solid #ccc;
padding: 0.2em 2em;
font-size: 100%;
cursor: pointer;
margin-top: 1em;
}
button:hover {
background: #ccc;
}
code {
background: #f0f0f0;
padding: 0 0.3em;
color: #396;
border-radius: 0.3em;
}
a:link, a:visited {
color: #69c;
text-decoration: none;
}
+2
View File
@@ -0,0 +1,2 @@
PROG = server
include ../examples.mk
+98
View File
@@ -0,0 +1,98 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
#include "mongoose.h"
struct device_settings {
char setting1[100];
char setting2[100];
};
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static struct device_settings s_settings = { "value1", "value2" };
static void handle_save(struct mg_connection *nc, struct http_message *hm) {
// Get form variables and store settings values
mg_get_http_var(&hm->body, "setting1", s_settings.setting1,
sizeof(s_settings.setting1));
mg_get_http_var(&hm->body, "setting2", s_settings.setting2,
sizeof(s_settings.setting2));
// Send response
mg_printf(nc, "%s", "HTTP/1.1 302 OK\r\nLocation: /\r\n\r\n");
}
static void handle_get_cpu_usage(struct mg_connection *nc) {
// Generate random value, as an example of changing CPU usage
// Getting real CPU usage depends on the OS.
int cpu_usage = (double) rand() / RAND_MAX * 100.0;
// Use chunked encoding in order to avoid calculating Content-Length
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
// Output JSON object which holds CPU usage data
mg_printf_http_chunk(nc, "{ \"result\": %d }", cpu_usage);
// Send empty chunk, the end of response
mg_send_http_chunk(nc, "", 0);
}
static void handle_ssi_call(struct mg_connection *nc, const char *param) {
if (strcmp(param, "setting1") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting1);
} else if (strcmp(param, "setting2") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting2);
}
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_HTTP_REQUEST:
if (mg_vcmp(&hm->uri, "/save") == 0) {
handle_save(nc, hm);
} else if (mg_vcmp(&hm->uri, "/get_cpu_usage") == 0) {
handle_get_cpu_usage(nc);
} else {
mg_serve_http(nc, hm, s_http_server_opts); // Serve static content
}
break;
case MG_EV_SSI_CALL:
handle_ssi_call(nc, ev_data);
break;
default:
break;
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
cs_stat_t st;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
if (nc == NULL) {
fprintf(stderr, "Cannot bind to %s\n", s_http_port);
exit(1);
}
// Set up HTTP server parameters
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = "web_root"; // Set up web root directory
if (mg_stat(s_http_server_opts.document_root, &st) != 0) {
fprintf(stderr, "%s", "Cannot find web_root directory, exiting\n");
exit(1);
}
printf("Starting web server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Connected device demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div class="content">
<img src="logo.png" style="float:right; height: 50px; border-radius: 3px;">
<h1>Connected device demo - RESTful call</h1>
<p>
This page is one of the series of examples that show how to make
devices connected with Mongoose. Here we add a RESTful call
to the Mongoose to show CPU usage stats on a dashboard.
RESTful call is done using Jquery's <code>ajax</code> call.
</p>
<h1>Settings section</h1>
<form method="POST" action="/save">
<fieldset>
<legend>Device settings</legend>
<label>Setting 1:</label> <input type="text"
name="setting1" value="<!--#call setting1 -->" >
<label>Setting 2:</label> <input type="text"
name="setting2" value="<!--#call setting2 -->" >
<div>
<button type="submit">Save Settings</button>
</div>
</fieldset>
</form>
<h1>Dashboard section</h1>
<label>CPU usage:</label> <span id="cpu_usage">&nbsp;</span>
</div>
</body>
</html>
@@ -0,0 +1,5 @@
/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^Line truncated
return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var Line truncated
return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[cLine truncated
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -0,0 +1,12 @@
$(document).ready(function() {
// Start 1-second timer to call RESTful endpoint
setInterval(function() {
$.ajax({
url: '/get_cpu_usage',
dataType: 'json',
success: function(json) {
$('#cpu_usage').text(json.result + '% ');
}
});
}, 1000);
});
@@ -0,0 +1,66 @@
* {
outline: none;
}
body {
background: #36c;
color: #555;
margin: 0;
padding: 0;
font: 16px/1.4 Helvetica, Arial, sans-serif;
}
div.content {
width: 800px;
margin: 1em auto;
padding: 2em;
background-color: #fff;
border-radius: 1em;
}
fieldset {
border: 1px solid #ccc;
padding: 1em;
}
fieldset legend {
font-style: italic;
color: silver;
}
fieldset label {
text-align: right;
padding: 0 1em;
}
input[type=text] {
font-size: 100%;
padding: 0.2em;
border: 1px solid #ccc;
}
button {
color: #666;
background: #eee;
border: 1px solid #ccc;
padding: 0.2em 2em;
font-size: 100%;
cursor: pointer;
margin-top: 1em;
}
button:hover {
background: #ccc;
}
code {
background: #f0f0f0;
padding: 0 0.3em;
color: #396;
border-radius: 0.3em;
}
a:link, a:visited {
color: #69c;
text-decoration: none;
}
+2
View File
@@ -0,0 +1,2 @@
PROG = server
include ../examples.mk
+115
View File
@@ -0,0 +1,115 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
#include "mongoose.h"
struct device_settings {
char setting1[100];
char setting2[100];
};
static const char *s_http_port = "8000";
static struct mg_serve_http_opts s_http_server_opts;
static struct device_settings s_settings = { "value1", "value2" };
static void handle_save(struct mg_connection *nc, struct http_message *hm) {
// Get form variables and store settings values
mg_get_http_var(&hm->body, "setting1", s_settings.setting1,
sizeof(s_settings.setting1));
mg_get_http_var(&hm->body, "setting2", s_settings.setting2,
sizeof(s_settings.setting2));
// Send response
mg_printf(nc, "%s", "HTTP/1.1 302 OK\r\nLocation: /\r\n\r\n");
}
static void handle_get_cpu_usage(struct mg_connection *nc) {
// Generate random value, as an example of changing CPU usage
// Getting real CPU usage depends on the OS.
int cpu_usage = (double) rand() / RAND_MAX * 100.0;
// Use chunked encoding in order to avoid calculating Content-Length
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
// Output JSON object which holds CPU usage data
mg_printf_http_chunk(nc, "{ \"result\": %d }", cpu_usage);
// Send empty chunk, the end of response
mg_send_http_chunk(nc, "", 0);
}
static void handle_ssi_call(struct mg_connection *nc, const char *param) {
if (strcmp(param, "setting1") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting1);
} else if (strcmp(param, "setting2") == 0) {
mg_printf_html_escape(nc, "%s", s_settings.setting2);
}
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_HTTP_REQUEST:
if (mg_vcmp(&hm->uri, "/save") == 0) {
handle_save(nc, hm);
} else if (mg_vcmp(&hm->uri, "/get_cpu_usage") == 0) {
handle_get_cpu_usage(nc);
} else {
mg_serve_http(nc, hm, s_http_server_opts); // Serve static content
}
break;
case MG_EV_SSI_CALL:
handle_ssi_call(nc, ev_data);
break;
default:
break;
}
}
static void push_data_to_all_websocket_connections(struct mg_mgr *m) {
struct mg_connection *c;
int memory_usage = (double) rand() / RAND_MAX * 100.0;
for (c = mg_next(m, NULL); c != NULL; c = mg_next(m, c)) {
if (c->flags & MG_F_IS_WEBSOCKET) {
mg_printf_websocket_frame(c, WEBSOCKET_OP_TEXT, "%d", memory_usage);
}
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
cs_stat_t st;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
if (nc == NULL) {
fprintf(stderr, "Cannot bind to %s\n", s_http_port);
exit(1);
}
// Set up HTTP server parameters
mg_set_protocol_http_websocket(nc);
s_http_server_opts.document_root = "web_root"; // Set up web root directory
if (mg_stat(s_http_server_opts.document_root, &st) != 0) {
fprintf(stderr, "%s", "Cannot find web_root directory, exiting\n");
exit(1);
}
printf("Starting web server on port %s\n", s_http_port);
for (;;) {
static time_t last_time;
time_t now = time(NULL);
mg_mgr_poll(&mgr, 1000);
if (now - last_time > 0) {
push_data_to_all_websocket_connections(&mgr);
last_time = now;
}
}
mg_mgr_free(&mgr);
return 0;
}
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Connected device demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="jquery-1.11.3.min.js"></script>
<script src="jquery.flot.min.js"></script>
<script src="jquery.flot.time.js"></script>
<script type="text/javascript" src="main.js"></script>
</head>
<body>
<div class="content">
<img src="logo.png" style="float:right; height: 50px; border-radius: 3px;">
<h1>Connected device demo - Websocket push</h1>
<p>
This page is one of the series of examples that show how to make
devices connected with Mongoose. Here we add a real-time Websocket
server push, and update dashboard graph as data arrives.
</p>
<h1>Settings section</h1>
<form method="POST" action="/save">
<fieldset>
<legend>Device settings</legend>
<label>Setting 1:</label> <input type="text"
name="setting1" value="<!--#call setting1 -->" >
<label>Setting 2:</label> <input type="text"
name="setting2" value="<!--#call setting2 -->" >
<div>
<button type="submit">Save Settings</button>
</div>
</fieldset>
</form>
<h1>Dashboard section</h1>
<label>CPU usage:</label> <span id="cpu_usage">&nbsp;</span>
<div id="graphs"></div>
</div>
</body>
</html>
@@ -0,0 +1,5 @@
/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l="1.11.3",m=function(a,b){return new m.fn.init(a,b)},n=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,o=/^-ms-/,p=/-([\da-z])/gi,q=function(a,b){return b.toUpperCase()};m.fn=m.prototype={jquery:l,constructor:m,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=m.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return m.each(this,a,b)},map:function(a){return this.pushStack(m.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},m.extend=m.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||m.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(e=arguments[h]))for(d in e)a=g[d],c=e[d],g!==c&&(j&&c&&(m.isPlainObject(c)||(b=m.isArray(c)))?(b?(b=!1,f=a&&m.isArray(a)?a:[]):f=a&&m.isPlainObject(a)?a:{},g[d]=m.extend(j,f,c)):void 0!==c&&(g[d]=c));return g},m.extend({expando:"jQuery"+(l+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===m.type(a)},isArray:Array.isArray||function(a){return"array"===m.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!m.isArray(a)&&a-parseFloat(a)+1>=0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},isPlainObject:function(a){var b;if(!a||"object"!==m.type(a)||a.nodeType||m.isWindow(a))return!1;try{if(a.constructor&&!j.call(a,"constructor")&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}if(k.ownLast)for(b in a)return j.call(a,b);for(b in a);return void 0===b||j.call(a,b)},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(b){b&&m.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(o,"ms-").replace(p,q)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=r(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(n,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(r(Object(a))?m.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){var d;if(b){if(g)return g.call(b,a,c);for(d=b.length,c=c?0>c?Math.max(0,d+c):c:0;d>c;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,b){var c=+b.length,d=0,e=a.length;while(c>d)a[e++]=b[d++];if(c!==c)while(void 0!==b[d])a[e++]=b[d++];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=r(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(f=a[b],b=a,a=f),m.isFunction(a)?(c=d.call(arguments,2),e=function(){return a.apply(b||this,c.concat(d.call(arguments)))},e.guid=a.guid=a.guid||m.guid++,e):void 0},now:function(){return+new Date},support:k}),m.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function r(a){var b="length"in a&&a.length,c=m.type(a);return"function"===c||m.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var s=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^Line truncated
return!0}function Q(a,b,d,e){if(m.acceptData(a)){var f,g,h=m.expando,i=a.nodeType,j=i?m.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||m.guid++:h),j[k]||(j[k]=i?{}:{toJSON:m.noop}),("object"==typeof b||"function"==typeof b)&&(e?j[k]=m.extend(j[k],b):j[k].data=m.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[m.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[m.camelCase(b)])):f=g,f}}function R(a,b,c){if(m.acceptData(a)){var d,e,f=a.nodeType,g=f?m.cache:a,h=f?a[m.expando]:m.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){m.isArray(b)?b=b.concat(m.map(b,m.camelCase)):b in d?b=[b]:(b=m.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!P(d):!m.isEmptyObject(d))return}(c||(delete g[h].data,P(g[h])))&&(f?m.cleanData([a],!0):k.deleteExpando||g!=g.window?delete g[h]:g[h]=null)}}}m.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(a){return a=a.nodeType?m.cache[a[m.expando]]:a[m.expando],!!a&&!P(a)},data:function(a,b,c){return Q(a,b,c)},removeData:function(a,b){return R(a,b)},_data:function(a,b,c){return Q(a,b,c,!0)},_removeData:function(a,b){return R(a,b,!0)}}),m.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=m.data(f),1===f.nodeType&&!m._data(f,"parsedAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=m.camelCase(d.slice(5)),O(f,d,e[d])));m._data(f,"parsedAttrs",!0)}return e}return"object"==typeof a?this.each(function(){m.data(this,a)}):arguments.length>1?this.each(function(){m.data(this,a,b)}):f?O(f,a,m.data(f,a)):void 0},removeData:function(a){return this.each(function(){m.removeData(this,a)})}}),m.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=m._data(a,b),c&&(!d||m.isArray(c)?d=m._data(a,b,m.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=m.queue(a,b),d=c.length,e=c.shift(),f=m._queueHooks(a,b),g=function(){m.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return m._data(a,c)||m._data(a,c,{empty:m.Callbacks("once memory").add(function(){m._removeData(a,b+"queue"),m._removeData(a,c)})})}}),m.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?m.queue(this[0],a):void 0===b?this:this.each(function(){var c=m.queue(this,a,b);m._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&m.dequeue(this,a)})},dequeue:function(a){return this.each(function(){m.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=m.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=m._data(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var S=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=["Top","Right","Bottom","Left"],U=function(a,b){return a=b||a,"none"===m.css(a,"display")||!m.contains(a.ownerDocument,a)},V=m.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===m.type(c)){e=!0;for(h in c)m.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,m.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(m(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f},W=/^(?:checkbox|radio)$/i;!function(){var a=y.createElement("input"),b=y.createElement("div"),c=y.createDocumentFragment();if(b.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",k.leadingWhitespace=3===b.firstChild.nodeType,k.tbody=!b.getElementsByTagName("tbody").length,k.htmlSerialize=!!b.getElementsByTagName("link").length,k.html5Clone="<:nav></:nav>"!==y.createElement("nav").cloneNode(!0).outerHTML,a.type="checkbox",a.checked=!0,c.appendChild(a),k.appendChecked=a.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue,c.appendChild(b),b.innerHTML="<input type='radio' checked='checked' name='t'/>",k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,k.noCloneEvent=!0,b.attachEvent&&(b.attachEvent("onclick",function(){k.noCloneEvent=!1}),b.cloneNode(!0).click()),null==k.deleteExpando){k.deleteExpando=!0;try{delete b.test}catch(d){k.deleteExpando=!1}}}(),function(){var b,c,d=y.createElement("div");for(b in{submit:!0,change:!0,focusin:!0})c="on"+b,(k[b+"Bubbles"]=c in a)||(d.setAttribute(c,"t"),k[b+"Bubbles"]=d.attributes[c].expando===!1);d=null}();var X=/^(?:input|select|textarea)$/i,Y=/^key/,Z=/^(?:mouse|pointer|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=/^([^.]*)(?:\.(.+)|)$/;function aa(){return!0}function ba(){return!1}function ca(){try{return y.activeElement}catch(a){}}m.event={global:{},add:function(a,b,c,d,e){var Line truncated
return new Za.prototype.init(a,b,c,d,e)}m.Tween=Za,Za.prototype={constructor:Za,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(m.cssNumber[c]?"":"px")},cur:function(){var a=Za.propHooks[this.prop];return a&&a.get?a.get(this):Za.propHooks._default.get(this)},run:function(a){var b,c=Za.propHooks[this.prop];return this.options.duration?this.pos=b=m.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):this.pos=b=a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Za.propHooks._default.set(this),this}},Za.prototype.init.prototype=Za.prototype,Za.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=m.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){m.fx.step[a.prop]?m.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[m.cssProps[a.prop]]||m.cssHooks[a.prop])?m.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Za.propHooks.scrollTop=Za.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},m.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},m.fx=Za.prototype.init,m.fx.step={};var $a,_a,ab=/^(?:toggle|show|hide)$/,bb=new RegExp("^(?:([+-])=|)("+S+")([a-z%]*)$","i"),cb=/queueHooks$/,db=[ib],eb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=bb.exec(b),f=e&&e[3]||(m.cssNumber[a]?"":"px"),g=(m.cssNumber[a]||"px"!==f&&+d)&&bb.exec(m.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,m.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function fb(){return setTimeout(function(){$a=void 0}),$a=m.now()}function gb(a,b){var c,d={height:a},e=0;for(b=b?1:0;4>e;e+=2-b)c=T[e],d["margin"+c]=d["padding"+c]=a;return b&&(d.opacity=d.width=a),d}function hb(a,b,c){for(var d,e=(eb[b]||[]).concat(eb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function ib(a,b,c){var d,e,f,g,h,i,j,l,n=this,o={},p=a.style,q=a.nodeType&&U(a),r=m._data(a,"fxshow");c.queue||(h=m._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,n.always(function(){n.always(function(){h.unqueued--,m.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[p.overflow,p.overflowX,p.overflowY],j=m.css(a,"display"),l="none"===j?m._data(a,"olddisplay")||Fa(a.nodeName):j,"inline"===l&&"none"===m.css(a,"float")&&(k.inlineBlockNeedsLayout&&"inline"!==Fa(a.nodeName)?p.zoom=1:p.display="inline-block")),c.overflow&&(p.overflow="hidden",k.shrinkWrapBlocks()||n.always(function(){p.overflow=c.overflow[0],p.overflowX=c.overflow[1],p.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],ab.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(q?"hide":"show")){if("show"!==e||!r||void 0===r[d])continue;q=!0}o[d]=r&&r[d]||m.style(a,d)}else j=void 0;if(m.isEmptyObject(o))"inline"===("none"===j?Fa(a.nodeName):j)&&(p.display=j);else{r?"hidden"in r&&(q=r.hidden):r=m._data(a,"fxshow",{}),f&&(r.hidden=!q),q?m(a).show():n.done(function(){m(a).hide()}),n.done(function(){var b;m._removeData(a,"fxshow");for(b in o)m.style(a,b,o[b])});for(d in o)g=hb(q?r[d]:0,d,n),d in r||(r[d]=g.start,q&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function jb(a,b){var c,d,e,f,g;for(c in a)if(d=m.camelCase(c),e=b[d],f=a[c],m.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=m.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function kb(a,b,c){var d,e,f=0,g=db.length,h=m.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=$a||fb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:m.extend({},b),opts:m.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:$a||fb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=m.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(jb(k,j.opts.specialEasing);g>f;f++)if(d=db[f].call(j,a,k,j.opts))return d;return m.map(k,hb,j),m.isFunction(j.opts.start)&&j.opts.start.call(a,j),m.fx.timer(m.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}m.Animation=m.extend(kb,{tweener:function(a,b){m.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],eb[cLine truncated
@@ -0,0 +1,8 @@
/* Javascript plotting library for jQuery, version 0.8.3.
Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license.
*/
(function($){$.color={};$.color.make=function(r,g,b,a){var o={};o.r=r||0;o.g=g||0;o.b=b||0;o.a=a!=null?a:1;o.add=function(c,d){for(var i=0;i<c.length;++i)o[c.charAt(i)]+=d;return o.normalize()};o.scale=function(c,f){for(var i=0;i<c.length;++i)o[c.charAt(i)]*=f;return o.normalize()};o.toString=function(){if(o.a>=1){return"rgb("+[o.r,o.g,o.b].join(",")+")"}else{return"rgba("+[o.r,o.g,o.b,o.a].join(",")+")"}};o.normalize=function(){function clamp(min,value,max){return value<min?min:value>max?max:value}o.r=clamp(0,parseInt(o.r),255);o.g=clamp(0,parseInt(o.g),255);o.b=clamp(0,parseInt(o.b),255);o.a=clamp(0,o.a,1);return o};o.clone=function(){return $.color.make(o.r,o.b,o.g,o.a)};return o.normalize()};$.color.extract=function(elem,css){var c;do{c=elem.css(css).toLowerCase();if(c!=""&&c!="transparent")break;elem=elem.parent()}while(elem.length&&!$.nodeName(elem.get(0),"body"));if(c=="rgba(0, 0, 0, 0)")c="transparent";return $.color.parse(c)};$.color.parse=function(str){var res,m=$.color.make;if(res=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10));if(res=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseInt(res[1],10),parseInt(res[2],10),parseInt(res[3],10),parseFloat(res[4]));if(res=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55);if(res=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))return m(parseFloat(res[1])*2.55,parseFloat(res[2])*2.55,parseFloat(res[3])*2.55,parseFloat(res[4]));if(res=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))return m(parseInt(res[1],16),parseInt(res[2],16),parseInt(res[3],16));if(res=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))return m(parseInt(res[1]+res[1],16),parseInt(res[2]+res[2],16),parseInt(res[3]+res[3],16));var name=$.trim(str).toLowerCase();if(name=="transparent")return m(255,255,255,0);else{res=lookupColors[name]||[0,0,0];return m(res[0],res[1],res[2])}};var lookupColors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery);(function($){var hasOwnProperty=Object.prototype.hasOwnProperty;if(!$.fn.detach){$.fn.detach=function(){return this.each(function(){if(this.parentNode){this.parentNode.removeChild(this)}})}}function Canvas(cls,container){var element=container.children("."+cls)[0];if(element==null){element=document.createElement("canvas");element.className=cls;$(element).css({direction:"ltr",position:"absolute",left:0,top:0}).appendTo(container);if(!element.getContext){if(window.G_vmlCanvasManager){element=window.G_vmlCanvasManager.initElement(element)}else{throw new Error("Canvas is not available. If you're using IE with a fall-back such as Excanvas, then there's either a mistake in your conditional include, or the page has no DOCTYPE and is rendering in Quirks Mode.")}}}this.element=element;var context=this.context=element.getContext("2d");var devicePixelRatio=window.devicePixelRatio||1,backingStoreRatio=context.webkitBackingStorePixelRatio||context.mozBackingStorePixelRatio||context.msBackingStorePixelRatio||context.oBackingStorePixelRatio||context.backingStorePixelRatio||1;this.pixelRatio=devicePixelRatio/backingStoreRatio;this.resize(container.width(),container.height());this.textContainer=null;this.text={};this._textCache={}}Canvas.prototype.resize=function(width,height){if(width<=0||height<=0){throw new Error("Invalid dimensions for plot, width = "+width+", height = "+height)}var element=this.element,context=this.context,pixelRatio=this.pixelRatio;if(this.width!=width){element.width=width*pixelRatio;element.style.width=width+"px";this.width=width}if(this.height!=height){element.height=height*pixelRatio;element.style.height=height+"px";this.height=height}context.restore();context.save();context.scale(pixelRatio,pixelRatio)};Canvas.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)};Canvas.prototype.render=function(){vaLine truncated
if(yrange.from==null)yrange.from=yrange.axis.min;if(yrange.to==null)yrange.to=yrange.axis.max;if(xrange.to<xrange.axis.min||xrange.from>xrange.axis.max||yrange.to<yrange.axis.min||yrange.from>yrange.axis.max)continue;xrange.from=Math.max(xrange.from,xrange.axis.min);xrange.to=Math.min(xrange.to,xrange.axis.max);yrange.from=Math.max(yrange.from,yrange.axis.min);yrange.to=Math.min(yrange.to,yrange.axis.max);var xequal=xrange.from===xrange.to,yequal=yrange.from===yrange.to;if(xequal&&yequal){continue}xrange.from=Math.floor(xrange.axis.p2c(xrange.from));xrange.to=Math.floor(xrange.axis.p2c(xrange.to));yrange.from=Math.floor(yrange.axis.p2c(yrange.from));yrange.to=Math.floor(yrange.axis.p2c(yrange.to));if(xequal||yequal){var lineWidth=m.lineWidth||options.grid.markingsLineWidth,subPixel=lineWidth%2?.5:0;ctx.beginPath();ctx.strokeStyle=m.color||options.grid.markingsColor;ctx.lineWidth=lineWidth;if(xequal){ctx.moveTo(xrange.to+subPixel,yrange.from);ctx.lineTo(xrange.to+subPixel,yrange.to)}else{ctx.moveTo(xrange.from,yrange.to+subPixel);ctx.lineTo(xrange.to,yrange.to+subPixel)}ctx.stroke()}else{ctx.fillStyle=m.color||options.grid.markingsColor;ctx.fillRect(xrange.from,yrange.to,xrange.to-xrange.from,yrange.from-yrange.to)}}}axes=allAxes();bw=options.grid.borderWidth;for(var j=0;j<axes.length;++j){var axis=axes[j],box=axis.box,t=axis.tickLength,x,y,xoff,yoff;if(!axis.show||axis.ticks.length==0)continue;ctx.lineWidth=1;if(axis.direction=="x"){x=0;if(t=="full")y=axis.position=="top"?0:plotHeight;else y=box.top-plotOffset.top+(axis.position=="top"?box.height:0)}else{y=0;if(t=="full")x=axis.position=="left"?0:plotWidth;else x=box.left-plotOffset.left+(axis.position=="left"?box.width:0)}if(!axis.innermost){ctx.strokeStyle=axis.options.color;ctx.beginPath();xoff=yoff=0;if(axis.direction=="x")xoff=plotWidth+1;else yoff=plotHeight+1;if(ctx.lineWidth==1){if(axis.direction=="x"){y=Math.floor(y)+.5}else{x=Math.floor(x)+.5}}ctx.moveTo(x,y);ctx.lineTo(x+xoff,y+yoff);ctx.stroke()}ctx.strokeStyle=axis.options.tickColor;ctx.beginPath();for(i=0;i<axis.ticks.length;++i){var v=axis.ticks[i].v;xoff=yoff=0;if(isNaN(v)||v<axis.min||v>axis.max||t=="full"&&(typeof bw=="object"&&bw[axis.position]>0||bw>0)&&(v==axis.min||v==axis.max))continue;if(axis.direction=="x"){x=axis.p2c(v);yoff=t=="full"?-plotHeight:t;if(axis.position=="top")yoff=-yoff}else{y=axis.p2c(v);xoff=t=="full"?-plotWidth:t;if(axis.position=="left")xoff=-xoff}if(ctx.lineWidth==1){if(axis.direction=="x")x=Math.floor(x)+.5;else y=Math.floor(y)+.5}ctx.moveTo(x,y);ctx.lineTo(x+xoff,y+yoff)}ctx.stroke()}if(bw){bc=options.grid.borderColor;if(typeof bw=="object"||typeof bc=="object"){if(typeof bw!=="object"){bw={top:bw,right:bw,bottom:bw,left:bw}}if(typeof bc!=="object"){bc={top:bc,right:bc,bottom:bc,left:bc}}if(bw.top>0){ctx.strokeStyle=bc.top;ctx.lineWidth=bw.top;ctx.beginPath();ctx.moveTo(0-bw.left,0-bw.top/2);ctx.lineTo(plotWidth,0-bw.top/2);ctx.stroke()}if(bw.right>0){ctx.strokeStyle=bc.right;ctx.lineWidth=bw.right;ctx.beginPath();ctx.moveTo(plotWidth+bw.right/2,0-bw.top);ctx.lineTo(plotWidth+bw.right/2,plotHeight);ctx.stroke()}if(bw.bottom>0){ctx.strokeStyle=bc.bottom;ctx.lineWidth=bw.bottom;ctx.beginPath();ctx.moveTo(plotWidth+bw.right,plotHeight+bw.bottom/2);ctx.lineTo(0,plotHeight+bw.bottom/2);ctx.stroke()}if(bw.left>0){ctx.strokeStyle=bc.left;ctx.lineWidth=bw.left;ctx.beginPath();ctx.moveTo(0-bw.left/2,plotHeight+bw.bottom);ctx.lineTo(0-bw.left/2,0);ctx.stroke()}}else{ctx.lineWidth=bw;ctx.strokeStyle=options.grid.borderColor;ctx.strokeRect(-bw/2,-bw/2,plotWidth+bw,plotHeight+bw)}}ctx.restore()}function drawAxisLabels(){$.each(allAxes(),function(_,axis){var box=axis.box,legacyStyles=axis.direction+"Axis "+axis.direction+axis.n+"Axis",layer="flot-"+axis.direction+"-axis flot-"+axis.direction+axis.n+"-axis "+legacyStyles,font=axis.options.font||"flot-tick-label tickLabel",tick,x,y,halign,valign;surface.removeText(layer);if(!axis.show||axis.ticks.length==0)return;for(var i=0;i<axis.ticks.length;++i){tick=axis.ticks[i];if(!tick.label||tick.v<axis.min||tick.v>axis.max)continue;if(axis.direction=="x"){halign="center";x=plotOffset.left+axis.p2c(tick.v);if(axis.position=="bottom"){y=box.top+box.padding}else{y=box.top+box.height-box.padding;valign="bottom"}}else{valign="middle";y=plotOffset.top+axis.p2c(tick.v);if(axis.position=="left"){x=box.left+box.width-box.padding;halign="right"}else{x=box.left+box.padding}}surface.addText(layer,x,y,tick.label,font,null,null,halign,valign)}})}function drawSeries(series){if(series.lines.show)drawSeriesLines(series);if(series.bars.show)drawSeriesBars(series);if(series.points.show)drawSeriesPoints(series)}function drawSeriesLines(series){function plotLine(datapoints,xoffset,yoffset,axisx,axisy){var points=datapoints.points,ps=datapoints.pointsize,prevx=null,prevy=null;ctx.beginPath();for(var i=ps;i<points.length;i+=ps){var x1=points[i-ps],y1=points[i-ps+1],x2=points[i],y2=points[i+1];if(x1==null||x2==null)continue;if(y1<=y2&&y1<axisy.min){if(y2<axLine truncated
@@ -0,0 +1,432 @@
/* Pretty handling of time axes.
Copyright (c) 2007-2014 IOLA and Ole Laursen.
Licensed under the MIT license.
Set axis.mode to "time" to enable. See the section "Time series data" in
API.txt for details.
*/
(function($) {
var options = {
xaxis: {
timezone: null, // "browser" for local to the client or timezone for timezone-js
timeformat: null, // format string to use
twelveHourClock: false, // 12 or 24 time in time mode
monthNames: null // list of names of months
}
};
// round to nearby lower multiple of base
function floorInBase(n, base) {
return base * Math.floor(n / base);
}
// Returns a string with the date d formatted according to fmt.
// A subset of the Open Group's strftime format is supported.
function formatDate(d, fmt, monthNames, dayNames) {
if (typeof d.strftime == "function") {
return d.strftime(fmt);
}
var leftPad = function(n, pad) {
n = "" + n;
pad = "" + (pad == null ? "0" : pad);
return n.length == 1 ? pad + n : n;
};
var r = [];
var escape = false;
var hours = d.getHours();
var isAM = hours < 12;
if (monthNames == null) {
monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
}
if (dayNames == null) {
dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
}
var hours12;
if (hours > 12) {
hours12 = hours - 12;
} else if (hours == 0) {
hours12 = 12;
} else {
hours12 = hours;
}
for (var i = 0; i < fmt.length; ++i) {
var c = fmt.charAt(i);
if (escape) {
switch (c) {
case 'a': c = "" + dayNames[d.getDay()]; break;
case 'b': c = "" + monthNames[d.getMonth()]; break;
case 'd': c = leftPad(d.getDate()); break;
case 'e': c = leftPad(d.getDate(), " "); break;
case 'h': // For back-compat with 0.7; remove in 1.0
case 'H': c = leftPad(hours); break;
case 'I': c = leftPad(hours12); break;
case 'l': c = leftPad(hours12, " "); break;
case 'm': c = leftPad(d.getMonth() + 1); break;
case 'M': c = leftPad(d.getMinutes()); break;
// quarters not in Open Group's strftime specification
case 'q':
c = "" + (Math.floor(d.getMonth() / 3) + 1); break;
case 'S': c = leftPad(d.getSeconds()); break;
case 'y': c = leftPad(d.getFullYear() % 100); break;
case 'Y': c = "" + d.getFullYear(); break;
case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break;
case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break;
case 'w': c = "" + d.getDay(); break;
}
r.push(c);
escape = false;
} else {
if (c == "%") {
escape = true;
} else {
r.push(c);
}
}
}
return r.join("");
}
// To have a consistent view of time-based data independent of which time
// zone the client happens to be in we need a date-like object independent
// of time zones. This is done through a wrapper that only calls the UTC
// versions of the accessor methods.
function makeUtcWrapper(d) {
function addProxyMethod(sourceObj, sourceMethod, targetObj, targetMethod) {
sourceObj[sourceMethod] = function() {
return targetObj[targetMethod].apply(targetObj, arguments);
};
};
var utc = {
date: d
};
// support strftime, if found
if (d.strftime != undefined) {
addProxyMethod(utc, "strftime", d, "strftime");
}
addProxyMethod(utc, "getTime", d, "getTime");
addProxyMethod(utc, "setTime", d, "setTime");
var props = ["Date", "Day", "FullYear", "Hours", "Milliseconds", "Minutes", "Month", "Seconds"];
for (var p = 0; p < props.length; p++) {
addProxyMethod(utc, "get" + props[p], d, "getUTC" + props[p]);
addProxyMethod(utc, "set" + props[p], d, "setUTC" + props[p]);
}
return utc;
};
// select time zone strategy. This returns a date-like object tied to the
// desired timezone
function dateGenerator(ts, opts) {
if (opts.timezone == "browser") {
return new Date(ts);
} else if (!opts.timezone || opts.timezone == "utc") {
return makeUtcWrapper(new Date(ts));
} else if (typeof timezoneJS != "undefined" && typeof timezoneJS.Date != "undefined") {
var d = new timezoneJS.Date();
// timezone-js is fickle, so be sure to set the time zone before
// setting the time.
d.setTimezone(opts.timezone);
d.setTime(ts);
return d;
} else {
return makeUtcWrapper(new Date(ts));
}
}
// map of app. size of time units in milliseconds
var timeUnitSize = {
"second": 1000,
"minute": 60 * 1000,
"hour": 60 * 60 * 1000,
"day": 24 * 60 * 60 * 1000,
"month": 30 * 24 * 60 * 60 * 1000,
"quarter": 3 * 30 * 24 * 60 * 60 * 1000,
"year": 365.2425 * 24 * 60 * 60 * 1000
};
// the allowed tick sizes, after 1 year we use
// an integer algorithm
var baseSpec = [
[1, "second"], [2, "second"], [5, "second"], [10, "second"],
[30, "second"],
[1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"],
[30, "minute"],
[1, "hour"], [2, "hour"], [4, "hour"],
[8, "hour"], [12, "hour"],
[1, "day"], [2, "day"], [3, "day"],
[0.25, "month"], [0.5, "month"], [1, "month"],
[2, "month"]
];
// we don't know which variant(s) we'll need yet, but generating both is
// cheap
var specMonths = baseSpec.concat([[3, "month"], [6, "month"],
[1, "year"]]);
var specQuarters = baseSpec.concat([[1, "quarter"], [2, "quarter"],
[1, "year"]]);
function init(plot) {
plot.hooks.processOptions.push(function (plot, options) {
$.each(plot.getAxes(), function(axisName, axis) {
var opts = axis.options;
if (opts.mode == "time") {
axis.tickGenerator = function(axis) {
var ticks = [];
var d = dateGenerator(axis.min, opts);
var minSize = 0;
// make quarter use a possibility if quarters are
// mentioned in either of these options
var spec = (opts.tickSize && opts.tickSize[1] ===
"quarter") ||
(opts.minTickSize && opts.minTickSize[1] ===
"quarter") ? specQuarters : specMonths;
if (opts.minTickSize != null) {
if (typeof opts.tickSize == "number") {
minSize = opts.tickSize;
} else {
minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]];
}
}
for (var i = 0; i < spec.length - 1; ++i) {
if (axis.delta < (spec[i][0] * timeUnitSize[spec[i][1]]
+ spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2
&& spec[i][0] * timeUnitSize[spec[i][1]] >= minSize) {
break;
}
}
var size = spec[i][0];
var unit = spec[i][1];
// special-case the possibility of several years
if (unit == "year") {
// if given a minTickSize in years, just use it,
// ensuring that it's an integer
if (opts.minTickSize != null && opts.minTickSize[1] == "year") {
size = Math.floor(opts.minTickSize[0]);
} else {
var magn = Math.pow(10, Math.floor(Math.log(axis.delta / timeUnitSize.year) / Math.LN10));
var norm = (axis.delta / timeUnitSize.year) / magn;
if (norm < 1.5) {
size = 1;
} else if (norm < 3) {
size = 2;
} else if (norm < 7.5) {
size = 5;
} else {
size = 10;
}
size *= magn;
}
// minimum size for years is 1
if (size < 1) {
size = 1;
}
}
axis.tickSize = opts.tickSize || [size, unit];
var tickSize = axis.tickSize[0];
unit = axis.tickSize[1];
var step = tickSize * timeUnitSize[unit];
if (unit == "second") {
d.setSeconds(floorInBase(d.getSeconds(), tickSize));
} else if (unit == "minute") {
d.setMinutes(floorInBase(d.getMinutes(), tickSize));
} else if (unit == "hour") {
d.setHours(floorInBase(d.getHours(), tickSize));
} else if (unit == "month") {
d.setMonth(floorInBase(d.getMonth(), tickSize));
} else if (unit == "quarter") {
d.setMonth(3 * floorInBase(d.getMonth() / 3,
tickSize));
} else if (unit == "year") {
d.setFullYear(floorInBase(d.getFullYear(), tickSize));
}
// reset smaller components
d.setMilliseconds(0);
if (step >= timeUnitSize.minute) {
d.setSeconds(0);
}
if (step >= timeUnitSize.hour) {
d.setMinutes(0);
}
if (step >= timeUnitSize.day) {
d.setHours(0);
}
if (step >= timeUnitSize.day * 4) {
d.setDate(1);
}
if (step >= timeUnitSize.month * 2) {
d.setMonth(floorInBase(d.getMonth(), 3));
}
if (step >= timeUnitSize.quarter * 2) {
d.setMonth(floorInBase(d.getMonth(), 6));
}
if (step >= timeUnitSize.year) {
d.setMonth(0);
}
var carry = 0;
var v = Number.NaN;
var prev;
do {
prev = v;
v = d.getTime();
ticks.push(v);
if (unit == "month" || unit == "quarter") {
if (tickSize < 1) {
// a bit complicated - we'll divide the
// month/quarter up but we need to take
// care of fractions so we don't end up in
// the middle of a day
d.setDate(1);
var start = d.getTime();
d.setMonth(d.getMonth() +
(unit == "quarter" ? 3 : 1));
var end = d.getTime();
d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize);
carry = d.getHours();
d.setHours(0);
} else {
d.setMonth(d.getMonth() +
tickSize * (unit == "quarter" ? 3 : 1));
}
} else if (unit == "year") {
d.setFullYear(d.getFullYear() + tickSize);
} else {
d.setTime(v + step);
}
} while (v < axis.max && v != prev);
return ticks;
};
axis.tickFormatter = function (v, axis) {
var d = dateGenerator(v, axis.options);
// first check global format
if (opts.timeformat != null) {
return formatDate(d, opts.timeformat, opts.monthNames, opts.dayNames);
}
// possibly use quarters if quarters are mentioned in
// any of these places
var useQuarters = (axis.options.tickSize &&
axis.options.tickSize[1] == "quarter") ||
(axis.options.minTickSize &&
axis.options.minTickSize[1] == "quarter");
var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]];
var span = axis.max - axis.min;
var suffix = (opts.twelveHourClock) ? " %p" : "";
var hourCode = (opts.twelveHourClock) ? "%I" : "%H";
var fmt;
if (t < timeUnitSize.minute) {
fmt = hourCode + ":%M:%S" + suffix;
} else if (t < timeUnitSize.day) {
if (span < 2 * timeUnitSize.day) {
fmt = hourCode + ":%M" + suffix;
} else {
fmt = "%b %d " + hourCode + ":%M" + suffix;
}
} else if (t < timeUnitSize.month) {
fmt = "%b %d";
} else if ((useQuarters && t < timeUnitSize.quarter) ||
(!useQuarters && t < timeUnitSize.year)) {
if (span < timeUnitSize.year) {
fmt = "%b";
} else {
fmt = "%b %Y";
}
} else if (useQuarters && t < timeUnitSize.year) {
if (span < timeUnitSize.year) {
fmt = "Q%q";
} else {
fmt = "Q%q %Y";
}
} else {
fmt = "%Y";
}
var rt = formatDate(d, fmt, opts.monthNames, opts.dayNames);
return rt;
};
}
});
});
}
$.plot.plugins.push({
init: init,
options: options,
name: 'time',
version: '1.0'
});
// Time-axis support used to be in Flot core, which exposed the
// formatDate function on the plot object. Various plugins depend
// on the function, so we need to re-expose it here.
$.plot.formatDate = formatDate;
$.plot.dateGenerator = dateGenerator;
})(jQuery);
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@@ -0,0 +1,75 @@
$(document).ready(function() {
// Start 1-second timer to call RESTful endpoint
setInterval(function() {
$.ajax({
url: '/get_cpu_usage',
dataType: 'json',
success: function(json) {
$('#cpu_usage').text(json.result + '% ');
}
});
}, 1000);
// Initialize graph
var $c = $('<div class="graph"/>').appendTo('#graphs');
var dur = 120;
var past = Date.now() - dur * 1000;
var options = {
lines: {
fill: true,
lineWidth: 0,
fillColor: {colors: [ { opacity: 0 }, { opacity: 1 } ] }
},
grid: { borderWidth: 1, borderColor: '#ccc'},
xaxis: { mode: 'time', ticks: 5 },
legend: { labelBoxBorderColor: '#fff' },
colors: [ '#fec', '#396', '#e39', '9e2' ],
hooks: {
draw: [function(plot, canvas) {
canvas.font = '13px sans-serif';
canvas.fillStyle = '#aaa';
canvas.fillText('Resource Usage', 35, 25);
}]
}
};
var plot = $.plot($c, [], options);
var updateGraph = function(counter) {
var data = plot.getData();
var now = Date.now();
var oldest = now - dur * 1000;
data[0] = {
show: false,
data: [[oldest, null], [now, null]]
};
console.log(data);
// Remove old points
$.each(data, function(di, d) {
while (d.data.length > 0 && d.data[0][0] < oldest) {
d.data.shift();
}
});
// Add new points
var new_datapoint = [now, counter];
if (data[1]) {
data[1].label = 'memory';
data[1].data.push(new_datapoint);
} else {
data[1] = [{ data: [new_datapoint] }];
}
// Redraw the graph
plot.setData(data);
plot.setupGrid();
plot.draw();
};
// Create Websocket connection. For simplicity, no reconnect logic is here.
var ws = new WebSocket('ws://' + location.host);
ws.onmessage = function(ev) {
updateGraph(ev.data);
};
});
@@ -0,0 +1,87 @@
* {
outline: none;
}
body {
background: #36c;
color: #555;
margin: 0;
padding: 0;
font: 16px/1.4 Helvetica, Arial, sans-serif;
}
div.content {
width: 800px;
margin: 1em auto;
padding: 2em;
background-color: #fff;
border-radius: 1em;
}
fieldset {
border: 1px solid #ccc;
padding: 1em;
}
fieldset legend {
font-style: italic;
color: silver;
}
fieldset label {
text-align: right;
padding: 0 1em;
}
input[type=text] {
font-size: 100%;
padding: 0.2em;
border: 1px solid #ccc;
}
button {
color: #666;
background: #eee;
border: 1px solid #ccc;
padding: 0.2em 2em;
font-size: 100%;
cursor: pointer;
margin-top: 1em;
}
button:hover {
background: #ccc;
}
code {
background: #f0f0f0;
padding: 0 0.3em;
color: #396;
border-radius: 0.3em;
}
a:link, a:visited {
color: #69c;
text-decoration: none;
}
#graphs {
margin-top: 1em;
}
.graph {
min-height: 12em;
border: 0px solid #ccc;
position: relative;
margin: 0 1em 1em 0;
width: 36em;
display: inline-block;
}
.graph_title {
position: absolute;
top: 0.5em; left: 1em;
color: #ccc;
font-weight: bold;
z-index: 999;
}
+13
View File
@@ -0,0 +1,13 @@
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -Wno-unused-function $(CFLAGS_EXTRA) $(MODULE_CFLAGS)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
-37
View File
@@ -1,37 +0,0 @@
#include <stdio.h>
#include <string.h>
#include "mongoose.h"
static void *callback(enum mg_event event,
struct mg_connection *conn) {
const struct mg_request_info *request_info = mg_get_request_info(conn);
if (event == MG_NEW_REQUEST) {
char content[1024];
int content_length = snprintf(content, sizeof(content),
"Hello from mongoose! Remote port: %d",
request_info->remote_port);
mg_printf(conn,
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: %d\r\n" // Always set Content-Length
"\r\n"
"%s",
content_length, content);
// Mark as processed
return "";
} else {
return NULL;
}
}
int main(void) {
struct mg_context *ctx;
const char *options[] = {"listening_ports", "8080", NULL};
ctx = mg_start(&callback, NULL, options);
getchar(); // Wait until user hits "enter"
mg_stop(ctx);
return 0;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

-73
View File
@@ -1,73 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
<!-- This file is part of the Mongoose project,
http://code.google.com/p/mongoose -->
<head>
<title>Mongoose chat server</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link type="text/css" rel="stylesheet" href="style.css"/>
<script src="jquery.js"></script>
<script src="main.js"></script>
</head>
<body>
<div id="header">
<div id="logo"></div>
<div class="rounded infobox help-message" id="motd">
Chat room implemented using
<a href="http://code.google.com/p/mongoose" target="_blank">Mongoose</a>
embeddable web server.
This application was written for educational purposes demonstrating
how web interface could be decoupled from the business logic. Not a
single line of HTML is generated by the server, instead, server
gives data to the client in JSON format.
</div>
</div>
<div>
<div id="middle">
<div><center><span id="error" class="rounded"></span><center></div>
<div id="menu">
<div class="menu-item left-rounded menu-item-selected"
name="chat">Chat</div>
<div class="menu-item left-rounded" name="settings">Settings</div>
</div>
<div id="content" class="rounded">
<div id="chat" class="main">
<div class="chat-window">
<span class="top-rounded chat-title">Main room</span>
<div class="bottom-rounded chat-content">
<div class="message-list" id="mml">
</div>
<input type="text" size="40" class="message-input"></input>
<span class="help-message">
Type your message here and press enter</span>
</div>
</div>
</div>
<div id="settings" class="hidden main">
<div>
<span class="top-rounded chat-title">Settings</span>
<div class="bottom-rounded chat-content">
<table>
<tr><td>Max messages to display:</td><td>blah blah</td></tr>
<tr><td>Text color:</td><td>blah blah</td></tr>
</table>
</div>
</div>
</div>
</div>
</div>
<div id="footer">
Copyright &copy; 2004-2010 by Sergey Lyubka
</div>
</body>
</html>
-154
View File
@@ -1,154 +0,0 @@
/*!
* jQuery JavaScript Library v1.4.2
* http://jquery.com/
*
* Copyright 2010, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
* http://sizzlejs.com/
* Copyright 2010, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: Sat Feb 13 22:33:48 2010 -0500
*/
(function(A,w){function ma(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(ma,1);return}c.ready()}}function Qa(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function X(a,b,d,f,e,j){var i=a.length;if(typeof b==="object"){for(var o in b)X(a,o,b[o],f,e,d);return a}if(d!==w){f=!j&&f&&c.isFunction(d);for(o=0;o<i;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,j);return a}return i?
e(a[0],b):w}function J(){return(new Date).getTime()}function Y(){return false}function Z(){return true}function na(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function oa(a){var b,d=[],f=[],e=arguments,j,i,o,k,n,r;i=c.data(this,"events");if(!(a.liveFired===this||!i||!i.live||a.button&&a.type==="click")){a.liveFired=this;var u=i.live.slice(0);for(k=0;k<u.length;k++){i=u[k];i.origType.replace(O,"")===a.type?f.push(i.selector):u.splice(k--,1)}j=c(a.target).closest(f,a.currentTarget);n=0;for(r=
j.length;n<r;n++)for(k=0;k<u.length;k++){i=u[k];if(j[n].selector===i.selector){o=j[n].elem;f=null;if(i.preType==="mouseenter"||i.preType==="mouseleave")f=c(a.relatedTarget).closest(i.selector)[0];if(!f||f!==o)d.push({elem:o,handleObj:i})}}n=0;for(r=d.length;n<r;n++){j=d[n];a.currentTarget=j.elem;a.data=j.handleObj.data;a.handleObj=j.handleObj;if(j.handleObj.origHandler.apply(j.elem,e)===false){b=false;break}}return b}}function pa(a,b){return"live."+(a&&a!=="*"?a+".":"")+b.replace(/\./g,"`").replace(/ /g,
"&")}function qa(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function ra(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var j in f)for(var i in f[j])c.event.add(this,j,f[j][i],f[j][i].data)}}})}function sa(a,b,d){var f,e,j;b=b&&b[0]?b[0].ownerDocument||b[0]:s;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===s&&!ta.test(a[0])&&(c.support.checkClone||!ua.test(a[0]))){e=
true;if(j=c.fragments[a[0]])if(j!==1)f=j}if(!f){f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=j?f:1;return{fragment:f,cacheable:e}}function K(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ra=A.jQuery,Sa=A.$,s=A.document,T,Ta=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Ua=/^.[^:#\[\.,]*$/,Va=/\S/,
Wa=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Xa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],L,$=Object.prototype.toString,aa=Object.prototype.hasOwnProperty,ba=Array.prototype.push,R=Array.prototype.slice,ya=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(a==="body"&&!b){this.context=s;this[0]=s.body;this.selector="body";this.length=1;return this}if(typeof a==="string")if((d=Ta.exec(a))&&
(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Xa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=sa([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}return c.merge(this,a)}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return T.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a);return c.merge(this,
a)}else return!b||b.jquery?(b||T).find(a):c(b).find(a);else if(c.isFunction(a))return T.ready(a);if(a.selector!==w){this.selector=a.selector;this.context=a.context}return c.makeArray(a,this)},selector:"",jquery:"1.4.2",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){var f=c();c.isArray(a)?ba.apply(f,a):c.merge(f,a);f.prevObject=this;f.context=this.context;if(b===
"find")f.selector=this.selector+(this.selector?" ":"")+d;else if(b)f.selector=this.selector+"."+b+"("+d+")";return f},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,
function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||c(null)},push:ba,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,j,i,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(j in e){i=a[j];o=e[j];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){i=i&&(c.isPlainObject(i)||
c.isArray(i))?i:c.isArray(o)?[]:{};a[j]=c.extend(f,i,o)}else if(o!==w)a[j]=o}return a};c.extend({noConflict:function(a){A.$=Sa;if(a)A.jQuery=Ra;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",
L,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",L);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&ma()}}},isFunction:function(a){return $.call(a)==="[object Function]"},isArray:function(a){return $.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||$.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!aa.call(a,"constructor")&&!aa.call(a.constructor.prototype,
"isPrototypeOf"))return false;var b;for(b in a);return b===w||aa.call(a,b)},isEmptyObject:function(a){for(var b in a)return false;return true},error:function(a){throw a;},parseJSON:function(a){if(typeof a!=="string"||!a)return null;a=c.trim(a);if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+
a))();else c.error("Invalid JSON: "+a)},noop:function(){},globalEval:function(a){if(a&&Va.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,j=a.length,i=j===w||c.isFunction(a);if(d)if(i)for(f in a){if(b.apply(a[f],
d)===false)break}else for(;e<j;){if(b.apply(a[e++],d)===false)break}else if(i)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<j&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Wa,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ba.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=0,f=b.length;d<f;d++)if(b[d]===
a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,j=a.length;e<j;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,j=0,i=a.length;j<i;j++){e=b(a[j],j,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b==="string"){d=a;a=d[b];b=w}else if(b&&
!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){a=a.toLowerCase();a=/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||!/compatible/.test(a)&&/(mozilla)(?:.*? rv:([\w.]+))?/.exec(a)||[];return{browser:a[1]||"",version:a[2]||"0"}},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=
true;if(ya)c.inArray=function(a,b){return ya.call(b,a)};T=c(s);if(s.addEventListener)L=function(){s.removeEventListener("DOMContentLoaded",L,false);c.ready()};else if(s.attachEvent)L=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",L);c.ready()}};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+J();d.style.display="none";d.innerHTML=" <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
var e=d.getElementsByTagName("*"),j=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!j)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(j.getAttribute("style")),hrefNormalized:j.getAttribute("href")==="/a",opacity:/^0.55$/.test(j.style.opacity),cssFloat:!!j.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,
parentNode:d.removeChild(d.appendChild(s.createElement("div"))).parentNode===null,deleteExpando:true,checkClone:false,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(i){}a.insertBefore(b,a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}try{delete b.test}catch(o){c.support.deleteExpando=false}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function k(){c.support.noCloneEvent=
false;d.detachEvent("onclick",k)});d.cloneNode(true).fireEvent("onclick")}d=s.createElement("div");d.innerHTML="<input type='radio' name='radiotest' checked='checked'/>";a=s.createDocumentFragment();a.appendChild(d.firstChild);c.support.checkClone=a.cloneNode(true).cloneNode(true).lastChild.checked;c(function(){var k=s.createElement("div");k.style.width=k.style.paddingLeft="1px";s.body.appendChild(k);c.boxModel=c.support.boxModel=k.offsetWidth===2;s.body.removeChild(k).style.display="none"});a=function(k){var n=
s.createElement("div");k="on"+k;var r=k in n;if(!r){n.setAttribute(k,"return;");r=typeof n[k]==="function"}return r};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=j=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var G="jQuery"+J(),Ya=0,za={};c.extend({cache:{},expando:G,noData:{embed:true,object:true,
applet:true},data:function(a,b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var f=a[G],e=c.cache;if(!f&&typeof b==="string"&&d===w)return null;f||(f=++Ya);if(typeof b==="object"){a[G]=f;e[f]=c.extend(true,{},b)}else if(!e[f]){a[G]=f;e[f]={}}a=e[f];if(d!==w)a[b]=d;return typeof b==="string"?a[b]:a}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?za:a;var d=a[G],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{if(c.support.deleteExpando)delete a[c.expando];
else a.removeAttribute&&a.removeAttribute(c.expando);delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,
a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===
w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var Aa=/[\n\t]/g,ca=/\s+/,Za=/\r/g,$a=/href|src|style/,ab=/(button|input)/i,bb=/(button|input|object|select|textarea)/i,
cb=/^(a|area)$/i,Ba=/radio|checkbox/;c.fn.extend({attr:function(a,b){return X(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(n){var r=c(this);r.addClass(a.call(this,n,r.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className){for(var j=" "+e.className+" ",
i=e.className,o=0,k=b.length;o<k;o++)if(j.indexOf(" "+b[o]+" ")<0)i+=" "+b[o];e.className=c.trim(i)}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(k){var n=c(this);n.removeClass(a.call(this,k,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(ca),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var j=(" "+e.className+" ").replace(Aa," "),i=0,o=b.length;i<o;i++)j=j.replace(" "+b[i]+" ",
" ");e.className=c.trim(j)}else e.className=""}return this},toggleClass:function(a,b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var j=c(this);j.toggleClass(a.call(this,e,j.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,j=0,i=c(this),o=b,k=a.split(ca);e=k[j++];){o=f?o:!i.hasClass(e);i[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=
this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(Aa," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var j=b?d:0;for(d=b?d+1:e.length;j<d;j++){var i=
e[j];if(i.selected){a=c(i).val();if(b)return a;f.push(a)}}return f}if(Ba.test(b.type)&&!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Za,"")}return w}var o=c.isFunction(a);return this.each(function(k){var n=c(this),r=a;if(this.nodeType===1){if(o)r=a.call(this,k,n.val());if(typeof r==="number")r+="";if(c.isArray(r)&&Ba.test(this.type))this.checked=c.inArray(n.val(),r)>=0;else if(c.nodeName(this,"select")){var u=c.makeArray(r);c("option",this).each(function(){this.selected=
c.inArray(c(this).val(),u)>=0});if(!u.length)this.selectedIndex=-1}else this.value=r}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var j=$a.test(b);if(b in a&&f&&!j){if(e){b==="type"&&ab.test(a.nodeName)&&a.parentNode&&c.error("type property can't be changed");
a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:bb.test(a.nodeName)||cb.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&j?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var O=/\.(.*)$/,db=function(a){return a.replace(/[^\w\s\.\|`]/g,
function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;var e,j;if(d.handler){e=d;d=e.handler}if(!d.guid)d.guid=c.guid++;if(j=c.data(a)){var i=j.events=j.events||{},o=j.handle;if(!o)j.handle=o=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(o.elem,arguments):w};o.elem=a;b=b.split(" ");for(var k,n=0,r;k=b[n++];){j=e?c.extend({},e):{handler:d,data:f};if(k.indexOf(".")>-1){r=k.split(".");
k=r.shift();j.namespace=r.slice(0).sort().join(".")}else{r=[];j.namespace=""}j.type=k;j.guid=d.guid;var u=i[k],z=c.event.special[k]||{};if(!u){u=i[k]=[];if(!z.setup||z.setup.call(a,f,r,o)===false)if(a.addEventListener)a.addEventListener(k,o,false);else a.attachEvent&&a.attachEvent("on"+k,o)}if(z.add){z.add.call(a,j);if(!j.handler.guid)j.handler.guid=d.guid}u.push(j);c.event.global[k]=true}a=null}}},global:{},remove:function(a,b,d,f){if(!(a.nodeType===3||a.nodeType===8)){var e,j=0,i,o,k,n,r,u,z=c.data(a),
C=z&&z.events;if(z&&C){if(b&&b.type){d=b.handler;b=b.type}if(!b||typeof b==="string"&&b.charAt(0)==="."){b=b||"";for(e in C)c.event.remove(a,e+b)}else{for(b=b.split(" ");e=b[j++];){n=e;i=e.indexOf(".")<0;o=[];if(!i){o=e.split(".");e=o.shift();k=new RegExp("(^|\\.)"+c.map(o.slice(0).sort(),db).join("\\.(?:.*\\.)?")+"(\\.|$)")}if(r=C[e])if(d){n=c.event.special[e]||{};for(B=f||0;B<r.length;B++){u=r[B];if(d.guid===u.guid){if(i||k.test(u.namespace)){f==null&&r.splice(B--,1);n.remove&&n.remove.call(a,u)}if(f!=
null)break}}if(r.length===0||f!=null&&r.length===1){if(!n.teardown||n.teardown.call(a,o)===false)Ca(a,e,z.handle);delete C[e]}}else for(var B=0;B<r.length;B++){u=r[B];if(i||k.test(u.namespace)){c.event.remove(a,n,u.handler,B);r.splice(B--,1)}}}if(c.isEmptyObject(C)){if(b=z.handle)b.elem=null;delete z.events;delete z.handle;c.isEmptyObject(z)&&c.removeData(a)}}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[G]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=
e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();c.event.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;(f=c.data(d,"handle"))&&f.apply(d,b);f=d.parentNode||d.ownerDocument;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()]))if(d["on"+e]&&d["on"+e].apply(d,b)===false)a.result=false}catch(j){}if(!a.isPropagationStopped()&&
f)c.event.trigger(a,b,f,true);else if(!a.isDefaultPrevented()){f=a.target;var i,o=c.nodeName(f,"a")&&e==="click",k=c.event.special[e]||{};if((!k._default||k._default.call(d,a)===false)&&!o&&!(f&&f.nodeName&&c.noData[f.nodeName.toLowerCase()])){try{if(f[e]){if(i=f["on"+e])f["on"+e]=null;c.event.triggered=true;f[e]()}}catch(n){}if(i)f["on"+e]=i;c.event.triggered=false}}},handle:function(a){var b,d,f,e;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;b=a.type.indexOf(".")<0&&!a.exclusive;
if(!b){d=a.type.split(".");a.type=d.shift();f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)")}e=c.data(this,"events");d=e[a.type];if(e&&d){d=d.slice(0);e=0;for(var j=d.length;e<j;e++){var i=d[e];if(b||f.test(i.namespace)){a.handler=i.handler;a.data=i.data;a.handleObj=i;i=i.handler.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}}return a.result},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
fix:function(a){if(a[G])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||
d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a){c.event.add(this,a.origType,c.extend({},a,{handler:oa}))},remove:function(a){var b=true,d=a.origType.replace(O,"");c.each(c.data(this,
"events").live||[],function(){if(d===this.origType.replace(O,""))return b=false});b&&c.event.remove(this,a.origType,oa)}},beforeunload:{setup:function(a,b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};var Ca=s.removeEventListener?function(a,b,d){a.removeEventListener(b,d,false)}:function(a,b,d){a.detachEvent("on"+b,d)};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=
a;this.type=a.type}else this.type=a;this.timeStamp=J();this[G]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=Z;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=Z;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z;this.stopPropagation()},isDefaultPrevented:Y,isPropagationStopped:Y,
isImmediatePropagationStopped:Y};var Da=function(a){var b=a.relatedTarget;try{for(;b&&b!==this;)b=b.parentNode;if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}}catch(d){}},Ea=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ea:Da,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ea:Da)}}});if(!c.support.submitBubbles)c.event.special.submit=
{setup:function(){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="submit"||d==="image")&&c(b).closest("form").length)return na("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit",function(a){var b=a.target,d=b.type;if((d==="text"||d==="password")&&c(b).closest("form").length&&a.keyCode===13)return na("submit",this,arguments)})}else return false},teardown:function(){c.event.remove(this,".specialSubmit")}};
if(!c.support.changeBubbles){var da=/textarea|input|select/i,ea,Fa=function(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d},fa=function(a,b){var d=a.target,f,e;if(!(!da.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Fa(d);if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",
e);if(!(f===w||e===f))if(f!=null||e){a.type="change";return c.event.trigger(a,b,d)}}};c.event.special.change={filters:{focusout:fa,click:function(a){var b=a.target,d=b.type;if(d==="radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return fa.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return fa.call(this,a)},beforeactivate:function(a){a=a.target;c.data(a,
"_change_data",Fa(a))}},setup:function(){if(this.type==="file")return false;for(var a in ea)c.event.add(this,a+".specialChange",ea[a]);return da.test(this.nodeName)},teardown:function(){c.event.remove(this,".specialChange");return da.test(this.nodeName)}};ea=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,
d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,f,e){if(typeof d==="object"){for(var j in d)this[b](j,f,d[j],e);return this}if(c.isFunction(f)){e=f;f=w}var i=b==="one"?c.proxy(e,function(k){c(this).unbind(k,i);return e.apply(this,arguments)}):e;if(d==="unload"&&b!=="one")this.one(d,f,e);else{j=0;for(var o=this.length;j<o;j++)c.event.add(this[j],d,i,f)}return this}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&
!a.preventDefault)for(var d in a)this.unbind(d,a[d]);else{d=0;for(var f=this.length;d<f;d++)c.event.remove(this[d],a,b)}return this},delegate:function(a,b,d,f){return this.live(b,d,f,a)},undelegate:function(a,b,d){return arguments.length===0?this.unbind("live"):this.die(b,null,d,a)},trigger:function(a,b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},
toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}});var Ga={focus:"focusin",blur:"focusout",mouseenter:"mouseover",mouseleave:"mouseout"};c.each(["live","die"],function(a,b){c.fn[b]=function(d,f,e,j){var i,o=0,k,n,r=j||this.selector,
u=j?this:c(this.context);if(c.isFunction(f)){e=f;f=w}for(d=(d||"").split(" ");(i=d[o++])!=null;){j=O.exec(i);k="";if(j){k=j[0];i=i.replace(O,"")}if(i==="hover")d.push("mouseenter"+k,"mouseleave"+k);else{n=i;if(i==="focus"||i==="blur"){d.push(Ga[i]+k);i+=k}else i=(Ga[i]||i)+k;b==="live"?u.each(function(){c.event.add(this,pa(i,r),{data:f,selector:r,handler:e,origType:i,origHandler:e,preType:n})}):u.unbind(pa(i,r),e)}}return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),
function(a,b){c.fn[b]=function(d){return d?this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",l,m=0;g[m];m++){l=g[m];if(l.nodeType===3||l.nodeType===4)h+=l.nodeValue;else if(l.nodeType!==8)h+=a(l.childNodes)}return h}function b(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];
if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1&&!p){t.sizcache=l;t.sizset=q}if(t.nodeName.toLowerCase()===h){y=t;break}t=t[g]}m[q]=y}}}function d(g,h,l,m,q,p){q=0;for(var v=m.length;q<v;q++){var t=m[q];if(t){t=t[g];for(var y=false;t;){if(t.sizcache===l){y=m[t.sizset];break}if(t.nodeType===1){if(!p){t.sizcache=l;t.sizset=q}if(typeof h!=="string"){if(t===h){y=true;break}}else if(k.filter(h,[t]).length>0){y=t;break}}t=t[g]}m[q]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
e=0,j=Object.prototype.toString,i=false,o=true;[0,0].sort(function(){o=false;return 0});var k=function(g,h,l,m){l=l||[];var q=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return l;for(var p=[],v,t,y,S,H=true,M=x(h),I=g;(f.exec(""),v=f.exec(I))!==null;){I=v[3];p.push(v[1]);if(v[2]){S=v[3];break}}if(p.length>1&&r.exec(g))if(p.length===2&&n.relative[p[0]])t=ga(p[0]+p[1],h);else for(t=n.relative[p[0]]?[h]:k(p.shift(),h);p.length;){g=p.shift();if(n.relative[g])g+=p.shift();
t=ga(g,t)}else{if(!m&&p.length>1&&h.nodeType===9&&!M&&n.match.ID.test(p[0])&&!n.match.ID.test(p[p.length-1])){v=k.find(p.shift(),h,M);h=v.expr?k.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:p.pop(),set:z(m)}:k.find(p.pop(),p.length===1&&(p[0]==="~"||p[0]==="+")&&h.parentNode?h.parentNode:h,M);t=v.expr?k.filter(v.expr,v.set):v.set;if(p.length>0)y=z(t);else H=false;for(;p.length;){var D=p.pop();v=D;if(n.relative[D])v=p.pop();else D="";if(v==null)v=h;n.relative[D](y,v,M)}}else y=[]}y||(y=t);y||k.error(D||
g);if(j.call(y)==="[object Array]")if(H)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&E(h,y[g])))l.push(t[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&l.push(t[g]);else l.push.apply(l,y);else z(y,l);if(S){k(S,q,l,m);k.uniqueSort(l)}return l};k.uniqueSort=function(g){if(B){i=o;g.sort(B);if(i)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};k.matches=function(g,h){return k(g,null,null,h)};k.find=function(g,h,l){var m,q;if(!g)return[];
for(var p=0,v=n.order.length;p<v;p++){var t=n.order[p];if(q=n.leftMatch[t].exec(g)){var y=q[1];q.splice(1,1);if(y.substr(y.length-1)!=="\\"){q[1]=(q[1]||"").replace(/\\/g,"");m=n.find[t](q,h,l);if(m!=null){g=g.replace(n.match[t],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};k.filter=function(g,h,l,m){for(var q=g,p=[],v=h,t,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var H in n.filter)if((t=n.leftMatch[H].exec(g))!=null&&t[2]){var M=n.filter[H],I,D;D=t[1];y=false;t.splice(1,1);if(D.substr(D.length-
1)!=="\\"){if(v===p)p=[];if(n.preFilter[H])if(t=n.preFilter[H](t,v,l,p,m,S)){if(t===true)continue}else y=I=true;if(t)for(var U=0;(D=v[U])!=null;U++)if(D){I=M(D,t,U,v);var Ha=m^!!I;if(l&&I!=null)if(Ha)y=true;else v[U]=false;else if(Ha){p.push(D);y=true}}if(I!==w){l||(v=p);g=g.replace(n.match[H],"");if(!y)return[];break}}}if(g===q)if(y==null)k.error(g);else break;q=g}return v};k.error=function(g){throw"Syntax error, unrecognized expression: "+g;};var n=k.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
relative:{"+":function(g,h){var l=typeof h==="string",m=l&&!/\W/.test(h);l=l&&!m;if(m)h=h.toLowerCase();m=0;for(var q=g.length,p;m<q;m++)if(p=g[m]){for(;(p=p.previousSibling)&&p.nodeType!==1;);g[m]=l||p&&p.nodeName.toLowerCase()===h?p||false:p===h}l&&k.filter(h,g,true)},">":function(g,h){var l=typeof h==="string";if(l&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,q=g.length;m<q;m++){var p=g[m];if(p){l=p.parentNode;g[m]=l.nodeName.toLowerCase()===h?l:false}}}else{m=0;for(q=g.length;m<q;m++)if(p=g[m])g[m]=
l?p.parentNode:p.parentNode===h;l&&k.filter(h,g,true)}},"":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("parentNode",h,m,g,p,l)},"~":function(g,h,l){var m=e++,q=d;if(typeof h==="string"&&!/\W/.test(h)){var p=h=h.toLowerCase();q=b}q("previousSibling",h,m,g,p,l)}},find:{ID:function(g,h,l){if(typeof h.getElementById!=="undefined"&&!l)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var l=[];
h=h.getElementsByName(g[1]);for(var m=0,q=h.length;m<q;m++)h[m].getAttribute("name")===g[1]&&l.push(h[m]);return l.length===0?null:l}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,l,m,q,p){g=" "+g[1].replace(/\\/g,"")+" ";if(p)return g;p=0;for(var v;(v=h[p])!=null;p++)if(v)if(q^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))l||m.push(v);else if(l)h[p]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,l,m,q,p){h=g[1].replace(/\\/g,"");if(!p&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,l,m,q){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=k(g[3],null,null,h);else{g=k.filter(g[3],h,l,true^q);l||m.push.apply(m,
g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,l){return!!k(l[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
setFilters:{first:function(g,h){return h===0},last:function(g,h,l,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,l){return h<l[3]-0},gt:function(g,h,l){return h>l[3]-0},nth:function(g,h,l){return l[3]-0===h},eq:function(g,h,l){return l[3]-0===h}},filter:{PSEUDO:function(g,h,l,m){var q=h[1],p=n.filters[q];if(p)return p(g,l,h,m);else if(q==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(q==="not"){h=
h[3];l=0;for(m=h.length;l<m;l++)if(h[l]===g)return false;return true}else k.error("Syntax error, unrecognized expression: "+q)},CHILD:function(g,h){var l=h[1],m=g;switch(l){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(l==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":l=h[2];var q=h[3];if(l===1&&q===0)return true;h=h[0];var p=g.parentNode;if(p&&(p.sizcache!==h||!g.nodeIndex)){var v=0;for(m=p.firstChild;m;m=
m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;p.sizcache=h}g=g.nodeIndex-q;return l===0?g===0:g%l===0&&g/l>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var l=h[1];g=n.attrHandle[l]?n.attrHandle[l](g):g[l]!=null?g[l]:g.getAttribute(l);l=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
"="?l===h:m==="*="?l.indexOf(h)>=0:m==="~="?(" "+l+" ").indexOf(h)>=0:!h?l&&g!==false:m==="!="?l!==h:m==="^="?l.indexOf(h)===0:m==="$="?l.substr(l.length-h.length)===h:m==="|="?l===h||l.substr(0,h.length+1)===h+"-":false},POS:function(g,h,l,m){var q=n.setFilters[h[2]];if(q)return q(g,l,h,m)}}},r=n.match.POS;for(var u in n.match){n.match[u]=new RegExp(n.match[u].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[u]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[u].source.replace(/\\(\d+)/g,function(g,
h){return"\\"+(h-0+1)}))}var z=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){z=function(g,h){h=h||[];if(j.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var l=0,m=g.length;l<m;l++)h.push(g[l]);else for(l=0;g[l];l++)h.push(g[l]);return h}}var B;if(s.documentElement.compareDocumentPosition)B=function(g,h){if(!g.compareDocumentPosition||
!h.compareDocumentPosition){if(g==h)i=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)i=true;return g};else if("sourceIndex"in s.documentElement)B=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)i=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)i=true;return g};else if(s.createRange)B=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)i=true;return g.ownerDocument?-1:1}var l=g.ownerDocument.createRange(),m=
h.ownerDocument.createRange();l.setStart(g,0);l.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=l.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)i=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var l=s.documentElement;l.insertBefore(g,l.firstChild);if(s.getElementById(h)){n.find.ID=function(m,q,p){if(typeof q.getElementById!=="undefined"&&!p)return(q=q.getElementById(m[1]))?q.id===m[1]||typeof q.getAttributeNode!=="undefined"&&
q.getAttributeNode("id").nodeValue===m[1]?[q]:w:[]};n.filter.ID=function(m,q){var p=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&p&&p.nodeValue===q}}l.removeChild(g);l=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,l){l=l.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;l[m];m++)l[m].nodeType===1&&h.push(l[m]);l=h}return l};g.innerHTML="<a href='#'></a>";
if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=k,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){k=function(m,q,p,v){q=q||s;if(!v&&q.nodeType===9&&!x(q))try{return z(q.querySelectorAll(m),p)}catch(t){}return g(m,q,p,v)};for(var l in g)k[l]=g[l];h=null}}();
(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,l,m){if(typeof l.getElementsByClassName!=="undefined"&&!m)return l.getElementsByClassName(h[1])};g=null}}})();var E=s.compareDocumentPosition?function(g,h){return!!(g.compareDocumentPosition(h)&16)}:
function(g,h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ga=function(g,h){var l=[],m="",q;for(h=h.nodeType?[h]:h;q=n.match.PSEUDO.exec(g);){m+=q[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;q=0;for(var p=h.length;q<p;q++)k(g,h[q],l);return k.filter(m,l)};c.find=k;c.expr=k.selectors;c.expr[":"]=c.expr.filters;c.unique=k.uniqueSort;c.text=a;c.isXMLDoc=x;c.contains=E})();var eb=/Until$/,fb=/^(?:parents|prevUntil|prevAll)/,
gb=/,/;R=Array.prototype.slice;var Ia=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,j){return!!b.call(e,j,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Ua.test(b))return c.filter(b,f,!d);else b=c.filter(b,f)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
c.find(a,this[f],b);if(f>0)for(var j=d;j<b.length;j++)for(var i=0;i<d;i++)if(b[i]===b[j]){b.splice(j--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Ia(this,a,false),"not",a)},filter:function(a){return this.pushStack(Ia(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,j=
{},i;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){i=a[e];j[i]||(j[i]=c.expr.match.POS.test(i)?c(i,b||this.context):i)}for(;f&&f.ownerDocument&&f!==b;){for(i in j){e=j[i];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:i,elem:f});delete j[i]}}f=f.parentNode}}return d}var k=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,r){for(;r&&r.ownerDocument&&r!==b;){if(k?k.index(r)>-1:c(r).is(a))return r;r=r.parentNode}return null})},index:function(a){if(!a||typeof a===
"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(qa(a[0])||qa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);eb.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||gb.test(f))&&fb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||a.nodeType!==1||!c(a).is(d));){a.nodeType===
1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ja=/ jQuery\d+="(?:\d+|null)"/g,V=/^\s+/,Ka=/(<([\w:]+)[^>]*?)\/>/g,hb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,La=/<([\w:]+)/,ib=/<tbody/i,jb=/<|&#?\w+;/,ta=/<script|<object|<embed|<option|<style/i,ua=/checked\s*(?:[^=]|=\s*.checked.)/i,Ma=function(a,b,d){return hb.test(d)?
a:b+"></"+d+">"},F={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};F.optgroup=F.option;F.tbody=F.tfoot=F.colgroup=F.caption=F.thead;F.th=F.td;if(!c.support.htmlSerialize)F._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=
c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},
prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,
this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,f;(f=this[d])!=null;d++)if(!a||c.filter(a,[f]).length){if(!b&&f.nodeType===1){c.cleanData(f.getElementsByTagName("*"));c.cleanData([f])}f.parentNode&&f.parentNode.removeChild(f)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);
return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ja,"").replace(/=([^="'>\s]+\/)>/g,'="$1">').replace(V,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ra(this,b);ra(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(Ja,
""):null;else if(typeof a==="string"&&!ta.test(a)&&(c.support.leadingWhitespace||!V.test(a))&&!F[(La.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ka,Ma);try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){c.cleanData(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}}else c.isFunction(a)?this.each(function(e){var j=c(this),i=j.html();j.empty().append(function(){return a.call(this,e,i)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
this[0].parentNode){if(c.isFunction(a))return this.each(function(b){var d=c(this),f=d.html();d.replaceWith(a.call(this,b,f))});if(typeof a!=="string")a=c(a).detach();return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(u){return c.nodeName(u,"table")?u.getElementsByTagName("tbody")[0]||
u.appendChild(u.ownerDocument.createElement("tbody")):u}var e,j,i=a[0],o=[],k;if(!c.support.checkClone&&arguments.length===3&&typeof i==="string"&&ua.test(i))return this.each(function(){c(this).domManip(a,b,d,true)});if(c.isFunction(i))return this.each(function(u){var z=c(this);a[0]=i.call(this,u,b?z.html():w);z.domManip(a,b,d)});if(this[0]){e=i&&i.parentNode;e=c.support.parentNode&&e&&e.nodeType===11&&e.childNodes.length===this.length?{fragment:e}:sa(a,this,o);k=e.fragment;if(j=k.childNodes.length===
1?(k=k.firstChild):k.firstChild){b=b&&c.nodeName(j,"tr");for(var n=0,r=this.length;n<r;n++)d.call(b?f(this[n],j):this[n],n>0||e.cacheable||this.length>1?k.cloneNode(true):k)}o.length&&c.each(o,Qa)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var f=[];d=c(d);var e=this.length===1&&this[0].parentNode;if(e&&e.nodeType===11&&e.childNodes.length===1&&d.length===1){d[b](this[0]);
return this}else{e=0;for(var j=d.length;e<j;e++){var i=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),i);f=f.concat(i)}return this.pushStack(f,a,d.selector)}}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;for(var e=[],j=0,i;(i=a[j])!=null;j++){if(typeof i==="number")i+="";if(i){if(typeof i==="string"&&!jb.test(i))i=b.createTextNode(i);else if(typeof i==="string"){i=i.replace(Ka,Ma);var o=(La.exec(i)||["",
""])[1].toLowerCase(),k=F[o]||F._default,n=k[0],r=b.createElement("div");for(r.innerHTML=k[1]+i+k[2];n--;)r=r.lastChild;if(!c.support.tbody){n=ib.test(i);o=o==="table"&&!n?r.firstChild&&r.firstChild.childNodes:k[1]==="<table>"&&!n?r.childNodes:[];for(k=o.length-1;k>=0;--k)c.nodeName(o[k],"tbody")&&!o[k].childNodes.length&&o[k].parentNode.removeChild(o[k])}!c.support.leadingWhitespace&&V.test(i)&&r.insertBefore(b.createTextNode(V.exec(i)[0]),r.firstChild);i=r.childNodes}if(i.nodeType)e.push(i);else e=
c.merge(e,i)}}if(d)for(j=0;e[j];j++)if(f&&c.nodeName(e[j],"script")&&(!e[j].type||e[j].type.toLowerCase()==="text/javascript"))f.push(e[j].parentNode?e[j].parentNode.removeChild(e[j]):e[j]);else{e[j].nodeType===1&&e.splice.apply(e,[j+1,0].concat(c.makeArray(e[j].getElementsByTagName("script"))));d.appendChild(e[j])}return e},cleanData:function(a){for(var b,d,f=c.cache,e=c.event.special,j=c.support.deleteExpando,i=0,o;(o=a[i])!=null;i++)if(d=o[c.expando]){b=f[d];if(b.events)for(var k in b.events)e[k]?
c.event.remove(o,k):Ca(o,k,b.handle);if(j)delete o[c.expando];else o.removeAttribute&&o.removeAttribute(c.expando);delete f[d]}}});var kb=/z-?index|font-?weight|opacity|zoom|line-?height/i,Na=/alpha\([^)]*\)/,Oa=/opacity=([^)]*)/,ha=/float/i,ia=/-([a-z])/ig,lb=/([A-Z])/g,mb=/^-?\d+(?:px)?$/i,nb=/^-?\d/,ob={position:"absolute",visibility:"hidden",display:"block"},pb=["Left","Right"],qb=["Top","Bottom"],rb=s.defaultView&&s.defaultView.getComputedStyle,Pa=c.support.cssFloat?"cssFloat":"styleFloat",ja=
function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return X(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!kb.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""==="NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=
Na.test(a)?a.replace(Na,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Oa.exec(f.filter)[1])/100+"":""}if(ha.test(b))b=Pa;b=b.replace(ia,ja);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,j=b==="width"?pb:qb;function i(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(j,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,
"border"+this+"Width",true))||0})}a.offsetWidth!==0?i():c.swap(a,ob,i);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Oa.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ha.test(b))b=Pa;if(!d&&e&&e[b])f=e[b];else if(rb){if(ha.test(b))b="float";b=b.replace(lb,"-$1").toLowerCase();e=a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=
a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ia,ja);f=a.currentStyle[b]||a.currentStyle[d];if(!mb.test(f)&&nb.test(f)){b=e.left;var j=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=j}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=
a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var sb=J(),tb=/<script(.|\s)*?\/script>/gi,ub=/select|textarea/i,vb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,N=/=\?(&|$)/,ka=/\?/,wb=/(\?|&)_=.*?(&|$)/,xb=/^(\w+:)?\/\/([^\/?#]+)/,yb=/%20/g,zb=c.fn.load;c.fn.extend({load:function(a,b,d){if(typeof a!==
"string")return zb.call(this,a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}var j=this;c.ajax({url:a,type:f,dataType:"html",data:b,complete:function(i,o){if(o==="success"||o==="notmodified")j.html(e?c("<div />").append(i.responseText.replace(tb,"")).find(e):i.responseText);d&&j.each(d,[i.responseText,o,i])}});return this},
serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ub.test(this.nodeName)||vb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),
function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,
global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&
e.success.call(k,o,i,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(k,x,i);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(q,p){(e.context?c(e.context):c.event).trigger(q,p)}var e=c.extend(true,{},c.ajaxSettings,a),j,i,o,k=a&&a.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,e.traditional);if(e.dataType==="jsonp"){if(n==="GET")N.test(e.url)||(e.url+=(ka.test(e.url)?
"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!N.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&N.test(e.data)||N.test(e.url))){j=e.jsonpCallback||"jsonp"+sb++;if(e.data)e.data=(e.data+"").replace(N,"="+j+"$1");e.url=e.url.replace(N,"="+j+"$1");e.dataType="script";A[j]=A[j]||function(q){o=q;b();d();A[j]=w;try{delete A[j]}catch(p){}z&&z.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===
false&&n==="GET"){var r=J(),u=e.url.replace(wb,"$1_="+r+"$2");e.url=u+(u===e.url?(ka.test(e.url)?"&":"?")+"_="+r:"")}if(e.data&&n==="GET")e.url+=(ka.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");r=(r=xb.exec(e.url))&&(r[1]&&r[1]!==location.protocol||r[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&r){var z=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!j){var B=
false;C.onload=C.onreadystatechange=function(){if(!B&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){B=true;b();d();C.onload=C.onreadystatechange=null;z&&C.parentNode&&z.removeChild(C)}}}z.insertBefore(C,z.firstChild);return w}var E=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",
c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}r||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ga){}if(e.beforeSend&&e.beforeSend.call(k,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",[x,e]);var g=x.onreadystatechange=function(q){if(!x||x.readyState===0||q==="abort"){E||
d();E=true;if(x)x.onreadystatechange=c.noop}else if(!E&&x&&(x.readyState===4||q==="timeout")){E=true;x.onreadystatechange=c.noop;i=q==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";var p;if(i==="success")try{o=c.httpData(x,e.dataType,e)}catch(v){i="parsererror";p=v}if(i==="success"||i==="notmodified")j||b();else c.handleError(e,x,i,p);d();q==="timeout"&&x.abort();if(e.async)x=null}};try{var h=x.abort;x.abort=function(){x&&h.call(x);
g("abort")}}catch(l){}e.async&&e.timeout>0&&setTimeout(function(){x&&!E&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||a,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol==="file:"||a.status>=200&&a.status<300||a.status===304||a.status===
1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;e&&a.documentElement.nodeName==="parsererror"&&c.error("parsererror");if(d&&d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b===
"json"||!b&&f.indexOf("json")>=0)a=c.parseJSON(a);else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(i,o){if(c.isArray(o))c.each(o,function(k,n){b||/\[\]$/.test(i)?f(i,n):d(i+"["+(typeof n==="object"||c.isArray(n)?k:"")+"]",n)});else!b&&o!=null&&typeof o==="object"?c.each(o,function(k,n){d(i+"["+k+"]",n)}):f(i,o)}function f(i,o){o=c.isFunction(o)?o():o;e[e.length]=encodeURIComponent(i)+"="+encodeURIComponent(o)}var e=[];if(b===w)b=c.ajaxSettings.traditional;
if(c.isArray(a)||a.jquery)c.each(a,function(){f(this.name,this.value)});else for(var j in a)d(j,a[j]);return e.join("&").replace(yb,"+")}});var la={},Ab=/toggle|show|hide/,Bb=/^([+-]=)?([\d+-.]+)(.*)$/,W,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a||a===0)return this.animate(K("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");
this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(la[d])f=la[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();la[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a||a===0)return this.animate(K("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],
"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(K("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},
animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var j=c.extend({},e),i,o=this.nodeType===1&&c(this).is(":hidden"),k=this;for(i in a){var n=i.replace(ia,ja);if(i!==n){a[n]=a[i];delete a[i];i=n}if(a[i]==="hide"&&o||a[i]==="show"&&!o)return j.complete.call(this);if((i==="height"||i==="width")&&this.style){j.display=c.css(this,"display");j.overflow=this.style.overflow}if(c.isArray(a[i])){(j.specialEasing=
j.specialEasing||{})[i]=a[i][1];a[i]=a[i][0]}}if(j.overflow!=null)this.style.overflow="hidden";j.curAnim=c.extend({},a);c.each(a,function(r,u){var z=new c.fx(k,j,r);if(Ab.test(u))z[u==="toggle"?o?"show":"hide":u](a);else{var C=Bb.exec(u),B=z.cur(true)||0;if(C){u=parseFloat(C[2]);var E=C[3]||"px";if(E!=="px"){k.style[r]=(u||1)+E;B=(u||1)/z.cur(true)*B;k.style[r]=B+E}if(C[1])u=(C[1]==="-="?-1:1)*u+B;z.custom(B,u,E)}else z.custom(B,u,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);
this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:K("show",1),slideUp:K("hide",1),slideToggle:K("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration===
"number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||
c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(j){return e.step(j)}this.startTime=J();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;
this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!W)W=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=J(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=
this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,
e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||
c.fx.stop()},stop:function(){clearInterval(W);W=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?
function(a){var b=this[0];if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=
this[0];if(a)return this.each(function(r){c.offset.setOffset(this,a,r)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=b,e=b.ownerDocument,j,i=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var k=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==i;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;j=e?e.getComputedStyle(b,null):b.currentStyle;
k-=b.scrollTop;n-=b.scrollLeft;if(b===d){k+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&j.overflow!=="visible"){k+=parseFloat(j.borderTopWidth)||0;n+=parseFloat(j.borderLeftWidth)||0}f=j}if(f.position==="relative"||f.position==="static"){k+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&
f.position==="fixed"){k+=Math.max(i.scrollTop,o.scrollTop);n+=Math.max(i.scrollLeft,o.scrollLeft)}return{top:k,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),d,f,e,j=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
a.insertBefore(b,a.firstChild);d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==j;a.removeChild(b);
c.offset.initialize=c.noop},bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),j=parseInt(c.curCSS(a,"top",true),10)||0,i=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,
d,e);d={top:b.top-e.top+j,left:b.left-e.left+i};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-
f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],j;if(!e)return null;if(f!==w)return this.each(function(){if(j=wa(this))j.scrollTo(!a?f:c(j).scrollLeft(),a?f:c(j).scrollTop());else this[d]=f});else return(j=wa(e))?"pageXOffset"in j?j[a?"pageYOffset":
"pageXOffset"]:c.support.boxModel&&j.document.documentElement[d]||j.document.body[d]:e[d]}});c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;if(c.isFunction(f))return this.each(function(j){var i=c(this);i[d](f.call(this,j,i[d]()))});return"scrollTo"in
e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
-43
View File
@@ -1,43 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr">
<!-- This file is part of the Mongoose project,
http://code.google.com/p/mongoose -->
<head>
<title>Mongoose chat: login</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<!--
Note that this page is self-sufficient, it does not load any other
CSS or Javascript file. This is done so because only this page is
allowed for non-authorized users. If we want to load other files
from the frontend, we need to change backend code to allow those
for non-authorized users. See chat.c :: must_authorize() function.
-->
</head>
<script>
window.onload = function() {
// Set correct action for the login form. We assume that the SSL port
// is the next one to insecure one.
var httpsPort = location.protocol.match(/https/) ? location.port :
parseInt(location.port) + 1;
document.forms[0].action = 'https://' + location.hostname + ':' +
httpsPort + '/authorize';
};
</script>
<body>
<center>
<h2>Mongoose chat server login</h2>
<div style="max-width: 30em;">
Username and password can be any non-empty strings.
</div>
<br/>
<form>
<input type="text" name="user"></input><br/>
<input type="text" name="password"></input><br/>
<input type="submit" value="Login"></input>
</form>
</center>
</body>
</html>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

-99
View File
@@ -1,99 +0,0 @@
// This file is part of Mongoose project, http://code.google.com/p/mongoose
var chat = {
// Backend URL, string.
// 'http://backend.address.com' or '' if backend is the same as frontend
backendUrl: '',
maxVisibleMessages: 10,
errorMessageFadeOutTimeoutMs: 2000,
errorMessageFadeOutTimer: null,
lastMessageId: 0,
getMessagesIntervalMs: 1000,
};
chat.normalizeText = function(text) {
return text.replace('<', '&lt;').replace('>', '&gt;');
};
chat.refresh = function(data) {
$.each(data, function(index, entry) {
var row = $('<div>').addClass('message-row').appendTo('#mml');
var timestamp = (new Date(entry.timestamp * 1000)).toLocaleTimeString();
$('<span>')
.addClass('message-timestamp')
.html('[' + timestamp + ']')
.prependTo(row);
$('<span>')
.addClass('message-user')
.addClass(entry.user ? '' : 'message-user-server')
.html(chat.normalizeText((entry.user || '[server]') + ':'))
.appendTo(row);
$('<span>')
.addClass('message-text')
.addClass(entry.user ? '' : 'message-text-server')
.html(chat.normalizeText(entry.text))
.appendTo(row);
chat.lastMessageId = Math.max(chat.lastMessageId, entry.id) + 1;
});
// Keep only chat.maxVisibleMessages, delete older ones.
while ($('#mml').children().length > chat.maxVisibleMessages) {
$('#mml div:first-child').remove();
}
};
chat.getMessages = function() {
$.ajax({
dataType: 'jsonp',
url: chat.backendUrl + '/ajax/get_messages',
data: {last_id: chat.lastMessageId},
success: chat.refresh,
error: function() {
},
});
window.setTimeout(chat.getMessages, chat.getMessagesIntervalMs);
};
chat.handleMenuItemClick = function(ev) {
$('.menu-item').removeClass('menu-item-selected'); // Deselect menu buttons
$(this).addClass('menu-item-selected'); // Select clicked button
$('.main').addClass('hidden'); // Hide all main windows
$('#' + $(this).attr('name')).removeClass('hidden'); // Show main window
};
chat.showError = function(message) {
$('#error').html(message).fadeIn('fast');
window.clearTimeout(chat.errorMessageFadeOutTimer);
chat.errorMessageFadeOutTimer = window.setTimeout(function() {
$('#error').fadeOut('slow');
}, chat.errorMessageFadeOutTimeoutMs);
};
chat.handleMessageInput = function(ev) {
var input = ev.target;
if (ev.keyCode != 13 || !input.value)
return;
//input.disabled = true;
$.ajax({
dataType: 'jsonp',
url: chat.backendUrl + '/ajax/send_message',
data: {text: input.value},
success: function(ev) {
input.value = '';
input.disabled = false;
chat.getMessages();
},
error: function(ev) {
chat.showError('Error sending message');
input.disabled = false;
},
});
};
$(document).ready(function() {
$('.menu-item').click(chat.handleMenuItemClick);
$('.message-input').keypress(chat.handleMessageInput);
chat.getMessages();
});
// vim:ts=2:sw=2:et
-154
View File
@@ -1,154 +0,0 @@
/*
* vim:ts=2:sw=2:et:ai
*/
body {
font: 13px Arial; margin: 0.5em 1em;
}
#logo {
background: url('logo.png') no-repeat ;
width: 160px;
height: 40px;
float: left;
}
td {
text-align: left;
}
#motd {
margin-left: 170px;
}
.infobox {
background: #eed;
padding: 1px 1em;
}
.help-message {
color: #aaa;
}
#middle {
margin: 0.5em 0;
}
#error {
background: #c44;
color: white;
font-weight: bold;
}
#content, .menu-item-selected, .chat-title, .chat-content {
background: #c3d9ff;
}
#content {
overflow: hidden;
min-height: 7em;
padding: 1em;
}
.chat-title {
padding: 1px 1ex;
}
.chat-content {
padding: 1ex;
}
.chat-window {
}
.message-row {
margin: 2px;
border-bottom: 1px solid #bbb;
}
.message-timestamp {
color: #484;
}
.message-user {
margin-left: 0.5em;
font-weight: bold;
}
.message-text {
margin-left: 0.5em;
}
.message-user-server {
color: purple;
}
.message-text-server {
font-style: italic;
}
.main {
padding: 0.5em;
background: #f0fcff;
}
#menu {
margin-top: 1em;
min-width: 7em;
float: left;
}
#footer {
position: fixed;
bottom: 0;
right: 0;
color: #ccc;
padding: 0.5em;
}
.section {
clear: both;
}
.hidden {
display: none;
}
.menu-item {
cursor: pointer;
padding: 0.1em 0.5em;
}
.menu-item-selected {
font-weight: bold;
}
.message-list {
min-height: 1em;
background: white;
margin: 0.5em 0;
}
.rounded {
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
.left-rounded {
border-radius: 6px 0 0 6px;
-moz-border-radius: 6px 0 0 6px;
-webkit-border-radius: 6px 0 0 6px;
}
.bottom-rounded {
border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
-webkit-border-radius: 0 0 6px 6px;
}
.top-rounded {
border-radius: 6px 6px 0 0;
-moz-border-radius: 6px 6px 0 0;
-webkit-border-radius: 6px 6px 0 0;
}
+14
View File
@@ -0,0 +1,14 @@
PROG = http_client
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -DMG_ENABLE_SSL -lssl -lcrypto -pthread $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+70
View File
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*
* This program fetches HTTP URLs.
*/
#include "mongoose.h"
static int s_exit_flag = 0;
static int s_show_headers = 0;
static const char *s_show_headers_opt = "--show-headers";
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_CONNECT:
if (* (int *) ev_data != 0) {
fprintf(stderr, "connect() failed: %s\n", strerror(* (int *) ev_data));
s_exit_flag = 1;
}
break;
case MG_EV_HTTP_REPLY:
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
if (s_show_headers) {
fwrite(hm->message.p, 1, hm->message.len, stdout);
} else {
fwrite(hm->body.p, 1, hm->body.len, stdout);
}
putchar('\n');
s_exit_flag = 1;
break;
default:
break;
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
int i;
mg_mgr_init(&mgr, NULL);
/* Process command line arguments */
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], s_show_headers_opt) == 0) {
s_show_headers = 1;
} else if (strcmp(argv[i], "--hexdump") == 0 && i + 1 < argc) {
mgr.hexdump_file = argv[++i];
} else {
break;
}
}
if (i + 1 != argc) {
fprintf(stderr, "Usage: %s [%s] [--hexdump <file>] <URL>\n",
argv[0], s_show_headers_opt);
exit(EXIT_FAILURE);
}
mg_connect_http(&mgr, ev_handler, argv[i], NULL, NULL);
while (s_exit_flag == 0) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
+163
View File
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\mongoose.c">
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">TurnOffAllWarnings</WarningLevel>
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">TurnOffAllWarnings</WarningLevel>
</ClCompile>
<ClCompile Include="http_client.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\mongoose.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BDF3FC6F-2658-4A27-846D-6A45FB53C602}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>http_client</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;MG_ENABLE_THREADS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>./../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;MG_ENABLE_THREADS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>./../../;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+14
View File
@@ -0,0 +1,14 @@
PROG = json_rpc_server
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -pthread $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
@@ -0,0 +1,67 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*
* To test this server, do
* $ curl -d '{"id":1,method:"sum",params:[22,33]}' 127.0.0.1:8000
*/
#include "mongoose.h"
static const char *s_http_port = "8000";
static int rpc_sum(char *buf, int len, struct mg_rpc_request *req) {
double sum = 0;
int i;
if (req->params[0].type != JSON_TYPE_ARRAY) {
return mg_rpc_create_std_error(buf, len, req,
JSON_RPC_INVALID_PARAMS_ERROR);
}
for (i = 0; i < req->params[0].num_desc; i++) {
if (req->params[i + 1].type != JSON_TYPE_NUMBER) {
return mg_rpc_create_std_error(buf, len, req,
JSON_RPC_INVALID_PARAMS_ERROR);
}
sum += strtod(req->params[i + 1].ptr, NULL);
}
return mg_rpc_create_reply(buf, len, req, "f", sum);
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct http_message *hm = (struct http_message *) ev_data;
static const char *methods[] = { "sum", NULL };
static mg_rpc_handler_t handlers[] = { rpc_sum, NULL };
char buf[100];
switch (ev) {
case MG_EV_HTTP_REQUEST:
mg_rpc_dispatch(hm->body.p, hm->body.len, buf, sizeof(buf),
methods, handlers);
mg_printf(nc, "HTTP/1.0 200 OK\r\nContent-Length: %d\r\n"
"Content-Type: application/json\r\n\r\n%s",
(int) strlen(buf), buf);
nc->flags |= MG_F_SEND_AND_CLOSE;
break;
default:
break;
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
mg_set_protocol_http_websocket(nc);
printf("Starting JSON-RPC server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return 0;
}
+10
View File
@@ -0,0 +1,10 @@
FROM cesanta/mongoose
COPY load_balancer.c /mongoose/
WORKDIR /mongoose
RUN mkdir /mongoose/certs; \
sed -i 's:#include "../../mongoose.h":#include "mongoose.h":' load_balancer.c; \
cc load_balancer.c mongoose.c -o load_balancer -W -Wall -pthread -DMG_ENABLE_SSL -lssl -lcrypto
EXPOSE 8000
VOLUME ["/mongoose/certs"]
ENTRYPOINT ["/mongoose/load_balancer"]
+39
View File
@@ -0,0 +1,39 @@
# To build with SSL under windows, do:
# wine make load_balancer.exe SSL=openssl # OpenSSL build
# wine make load_balancer.exe SSL=krypton # Krypton build
PROG = load_balancer
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -pthread $(CFLAGS_EXTRA)
ifeq ($(SSL), openssl)
OPENSSL_PATH = ./openssl-0.9.8
CFLAGS_EXTRA += -DMG_ENABLE_SSL -I$(OPENSSL_PATH)/include
CFLAGS_EXTRA += /link /libpath:$(OPENSSL_PATH)/lib ssleay32.lib libeay32.lib
endif
ifeq ($(SSL), krypton)
KRYPTON_PATH = ../../../krypton
CFLAGS_EXTRA += -DMG_ENABLE_SSL $(KRYPTON_PATH)/krypton.c -I$(KRYPTON_PATH)
endif
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I.. /MD /Fe$@ /DMG_ENABLE_THREADS advapi32.lib $(CFLAGS_EXTRA)
test: $(PROG)
$(MAKE) -C ../api_server
sh unit_test.sh $$(pwd)/$(PROG)
docker-build:
docker build -t cesanta/load_balancer .
docker-push:
docker push cesanta/load_balancer
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+44
View File
@@ -0,0 +1,44 @@
# Mongoose-based HTTP load balancer
## Configuration
Load balancer is configured with command-line flags.
### Global flags
* `-p port` – TCP port to listen on. Default: 8000.
* `-l log_file` – path to the log file. Default: none.
* `-s ssl_cert` – path to SSL certificate. Default: none.
### Backend configuration
Main flag is `-b uri_prefix host_port` – it adds a new backend for a given
URI prefix. Example: `-b /stuff/ 127.0.0.1:8080` will route all requests that
start with '/stuff/' to a backend at port 8080 on localhost. There is a special
syntax for `uri_prefix` that allows you to change the URIs that get passed to
backends:
* `-b /stuff/=/ 127.0.0.1:8080` – for '/stuff/thing' backend will see '/thing'.
* `-b /stuff/=/other/ 127.0.0.1:8080` – '/stuff/thing' => '/other/thing'.
Also there are few per-backend flags that can be placed before `-b` and apply
only to the next backend:
* `-r` – instead of proxying requests load balancer will reply with 302
redirect.
* `-v vhost` – match not only URI prefix but 'Host:' header as well.
### Example
```
load_balancer -s path/to/cert.pem \
-v example.com -b /site/=/ 127.0.0.1:8080 \
-b /static/ 127.0.0.1:8081 \
-b /static/ 127.0.0.1:8082
```
In this example requests to 'example.com/site/' will be forwarded to the
backend on port 8080 with '/site' prefix stripped off and requests to
'/static/' on any virtual host will be balanced in round-robin fashion between
backends on ports 8081 and 8082.
+645
View File
@@ -0,0 +1,645 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
#include "../../mongoose.h"
#include <sys/queue.h>
#define MAX_IDLE_CONNS 5
#define CONN_IDLE_TIMEOUT 30
struct http_backend;
struct be_conn {
struct http_backend *be;
struct mg_connection *nc;
time_t idle_deadline;
STAILQ_ENTRY(be_conn) conns;
};
STAILQ_HEAD(be_conn_list_head, be_conn);
struct http_backend {
const char *vhost; /* NULL if any host */
const char *uri_prefix; /* URI prefix, e.g. "/api/v1/", "/static/" */
const char *uri_prefix_replacement; /* if not NULL, will replace uri_prefix in
requests to backends */
const char *host_port; /* Backend address */
int redirect; /* if true redirect instead of proxy */
int usage_counter; /* Number of times this backend was chosen */
struct be_conn_list_head conns;
int num_conns;
};
struct peer {
struct mg_connection *nc;
int64_t body_len; /* Size of the HTTP body to forward */
int64_t body_sent; /* Number of bytes already forwarded */
struct {
/* Headers have been sent, no more headers. */
unsigned int headers_sent : 1;
unsigned int keep_alive : 1;
} flags;
};
struct conn_data {
struct be_conn *be_conn; /* Chosen backend */
struct peer client; /* Client peer */
struct peer backend; /* Backend peer */
time_t last_activity;
};
static const char *s_error_500 = "HTTP/1.1 500 Failed\r\n";
static const char *s_content_len_0 = "Content-Length: 0\r\n";
static const char *s_connection_close = "Connection: close\r\n";
static const char *s_http_port = "8000";
static struct http_backend s_vhost_backends[100], s_default_backends[100];
static int s_num_vhost_backends = 0, s_num_default_backends = 0;
static int s_sig_num = 0;
static int s_backend_keepalive = 0;
static FILE *s_log_file = NULL;
#ifdef MG_ENABLE_SSL
const char *s_ssl_cert = NULL;
#endif
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data);
static void write_log(const char *fmt, ...);
static void signal_handler(int sig_num) {
signal(sig_num, signal_handler);
s_sig_num = sig_num;
}
static void send_http_err(struct mg_connection *nc, const char *err_line) {
mg_printf(nc, "%s%s%s\r\n", err_line, s_content_len_0, s_connection_close);
}
static void respond_with_error(struct conn_data *conn, const char *err_line) {
struct mg_connection *nc = conn->client.nc;
int headers_sent = conn->client.flags.headers_sent;
#ifdef DEBUG
write_log("conn=%p nc=%p respond_with_error %d\n", conn, nc, headers_sent);
#endif
if (nc == NULL) return;
if (!headers_sent) {
send_http_err(nc, err_line);
conn->client.flags.headers_sent = 1;
}
nc->flags |= MG_F_SEND_AND_CLOSE;
}
static int has_prefix(const struct mg_str *uri, const char *prefix) {
size_t prefix_len = strlen(prefix);
return uri->len >= prefix_len && memcmp(uri->p, prefix, prefix_len) == 0;
}
static int matches_vhost(const struct mg_str *host, const char *vhost) {
size_t vhost_len;
if (vhost == NULL) {
return 1;
}
vhost_len = strlen(vhost);
return host->len == vhost_len && memcmp(host->p, vhost, vhost_len) == 0;
}
static void write_log(const char *fmt, ...) {
va_list ap;
if (s_log_file != NULL) {
va_start(ap, fmt);
vfprintf(s_log_file, fmt, ap);
fflush(s_log_file);
va_end(ap);
}
}
static struct http_backend *choose_backend_from_list(
struct http_message *hm, struct http_backend *backends, int num_backends) {
int i;
struct mg_str vhost = {"", 0};
const struct mg_str *host = mg_get_http_header(hm, "host");
if (host != NULL) vhost = *host;
const char *vhost_end = vhost.p;
while (vhost_end < vhost.p + vhost.len && *vhost_end != ':') {
vhost_end++;
}
vhost.len = vhost_end - vhost.p;
struct http_backend *chosen = NULL;
for (i = 0; i < num_backends; i++) {
struct http_backend *be = &backends[i];
if (has_prefix(&hm->uri, be->uri_prefix) &&
matches_vhost(&vhost, be->vhost) &&
(chosen == NULL ||
/* Prefer most specific URI prefixes */
strlen(be->uri_prefix) > strlen(chosen->uri_prefix) ||
/* Among prefixes of the same length chose the least used. */
(strlen(be->uri_prefix) == strlen(chosen->uri_prefix) &&
be->usage_counter < chosen->usage_counter))) {
chosen = be;
}
}
return chosen;
}
static struct http_backend *choose_backend(struct http_message *hm) {
struct http_backend *chosen =
choose_backend_from_list(hm, s_vhost_backends, s_num_vhost_backends);
/* Nothing was chosen for this vhost, look for vhost == NULL backends. */
if (chosen == NULL) {
chosen = choose_backend_from_list(hm, s_default_backends,
s_num_default_backends);
}
if (chosen != NULL) chosen->usage_counter++;
return chosen;
}
static void forward_body(struct peer *src, struct peer *dst) {
struct mbuf *src_io = &src->nc->recv_mbuf;
if (src->body_sent < src->body_len) {
size_t to_send = src->body_len - src->body_sent;
if (src_io->len < to_send) {
to_send = src_io->len;
}
mg_send(dst->nc, src_io->buf, to_send);
src->body_sent += to_send;
mbuf_remove(src_io, to_send);
}
#ifdef DEBUG
write_log("forward_body %p (ka=%d) -> %p sent %d of %d\n", src->nc,
src->flags.keep_alive, dst->nc, src->body_sent, src->body_len);
#endif
}
static void forward(struct conn_data *conn, struct http_message *hm,
struct peer *src_peer, struct peer *dst_peer) {
struct mg_connection *src = src_peer->nc;
struct mg_connection *dst = dst_peer->nc;
struct mbuf *io = &src->recv_mbuf;
int i;
int is_request = (src_peer == &conn->client);
src_peer->body_len = hm->body.len;
struct http_backend *be = conn->be_conn->be;
if (is_request) {
/* Write rewritten request line. */
size_t trim_len = strlen(be->uri_prefix);
mg_printf(dst, "%.*s%s%.*s\r\n", (int) (hm->uri.p - io->buf), io->buf,
be->uri_prefix_replacement,
(int) (hm->proto.p + hm->proto.len - (hm->uri.p + trim_len)),
hm->uri.p + trim_len);
} else {
/* Reply line goes without modification */
mg_printf(dst, "%.*s %d %.*s\r\n", (int) hm->proto.len, hm->proto.p,
(int) hm->resp_code, (int) hm->resp_status_msg.len,
hm->resp_status_msg.p);
}
/* Headers. */
for (i = 0; i < MG_MAX_HTTP_HEADERS && hm->header_names[i].len > 0; i++) {
struct mg_str hn = hm->header_names[i];
struct mg_str hv = hm->header_values[i];
#ifdef MG_ENABLE_SSL
/*
* If we terminate SSL and backend redirects to local HTTP port,
* strip protocol to let client use HTTPS.
* TODO(lsm): web page content may also contain local HTTP references,
* they need to be rewritten too.
*/
if (mg_vcasecmp(&hn, "Location") == 0 && s_ssl_cert != NULL) {
size_t hlen = strlen(be->host_port);
const char *hp = be->host_port, *p = memchr(hp, ':', hlen);
if (p == NULL) {
p = hp + hlen;
}
if (mg_ncasecmp(hv.p, "http://", 7) == 0 &&
mg_ncasecmp(hv.p + 7, hp, (p - hp)) == 0) {
mg_printf(dst, "Location: %.*s\r\n", (int) (hv.len - (7 + (p - hp))),
hv.p + 7 + (p - hp));
continue;
}
}
#endif
/* We always rewrite the connection header depending on the settings. */
if (mg_vcasecmp(&hn, "Connection") == 0) continue;
/* Don't pass chunked transfer encoding to the client */
if (mg_vcasecmp(&hn, "Transfer-encoding") == 0 &&
mg_vcasecmp(&hv, "chunked") == 0) {
continue;
}
mg_printf(dst, "%.*s: %.*s\r\n", (int) hn.len, hn.p, (int) hv.len, hv.p);
}
/* Emit the connection header. */
const char *connection_mode = "close";
if (dst_peer == &conn->backend) {
if (s_backend_keepalive) connection_mode = "keep-alive";
} else {
if (conn->client.flags.keep_alive) connection_mode = "keep-alive";
}
mg_printf(dst, "Connection: %s\r\n", connection_mode);
mg_printf(dst, "%s", "\r\n");
mbuf_remove(io, hm->body.p - hm->message.p); /* We've forwarded headers */
dst_peer->flags.headers_sent = 1;
forward_body(src_peer, dst_peer);
}
struct be_conn *get_conn(struct http_backend *be) {
if (STAILQ_EMPTY(&be->conns)) return NULL;
struct be_conn *result = STAILQ_FIRST(&be->conns);
STAILQ_REMOVE_HEAD(&be->conns, conns);
be->num_conns--;
return result;
}
/*
* choose_backend parses incoming HTTP request and routes it to the appropriate
* backend. It assumes that clients don't do HTTP pipelining, handling only
* one request request for each connection. To give a hint to backend about
* this it inserts "Connection: close" header into each forwarded request.
*/
static int connect_backend(struct conn_data *conn, struct http_message *hm) {
struct mg_connection *nc = conn->client.nc;
struct http_backend *be = choose_backend(hm);
write_log("%.*s %.*s backend=%s\n", (int) hm->method.len, hm->method.p,
(int) hm->uri.len, hm->uri.p, be ? be->host_port : "not defined");
if (be == NULL) return 0;
if (be->redirect != 0) {
mg_printf(nc, "HTTP/1.1 302 Found\r\nLocation: %s\r\n\r\n", be->host_port);
return 1;
}
struct be_conn *bec = get_conn(be);
if (bec != NULL) {
bec->nc->handler = ev_handler;
#ifdef DEBUG
write_log("conn=%p to %p (%s) reusing bec=%p\n", conn, be, be->host_port,
bec);
#endif
} else {
bec = malloc(sizeof(*conn->be_conn));
memset(bec, 0, sizeof(*bec));
bec->nc = mg_connect(nc->mgr, be->host_port, ev_handler);
#ifdef DEBUG
write_log("conn=%p new conn to %p (%s) bec=%p\n", conn, be, be->host_port,
bec);
#endif
if (bec->nc == NULL) {
free(bec);
write_log("Connection to [%s] failed\n", be->host_port);
return 0;
}
}
bec->be = be;
conn->be_conn = bec;
conn->backend.nc = bec->nc;
conn->backend.nc->user_data = conn;
mg_set_protocol_http_websocket(conn->backend.nc);
return 1;
}
static int is_keep_alive(struct http_message *hm) {
const struct mg_str *connection_header = mg_get_http_header(hm, "Connection");
if (connection_header == NULL) {
/* HTTP/1.1 connections are keep-alive by default. */
if (mg_vcasecmp(&hm->proto, "HTTP/1.1") != 0) return 0;
} else if (mg_vcasecmp(connection_header, "keep-alive") != 0) {
return 0;
}
// We must also have Content-Length.
return mg_get_http_header(hm, "Content-Length") != NULL;
}
static void idle_backend_handler(struct mg_connection *nc, int ev,
void *ev_data) {
(void) ev_data; /* Unused. */
struct be_conn *bec = nc->user_data;
const time_t now = time(NULL);
#ifdef DEBUG
write_log("%d idle bec=%p nc=%p ev=%d deadline=%d\n", now, bec, nc, ev,
bec->idle_deadline);
#endif
switch (ev) {
case MG_EV_POLL: {
if (bec->idle_deadline > 0 && now > bec->idle_deadline) {
#ifdef DEBUG
write_log("bec=%p nc=%p closing due to idleness\n", bec, bec->nc);
#endif
bec->nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
break;
}
case MG_EV_CLOSE: {
#ifdef DEBUG
write_log("bec=%p closed\n", bec);
#endif
if (bec->idle_deadline > 0) {
STAILQ_REMOVE(&bec->be->conns, bec, be_conn, conns);
}
free(bec);
break;
}
}
}
void release_backend(struct conn_data *conn) {
/* Disassociate the backend, put back on the pool. */
struct be_conn *bec = conn->be_conn;
conn->be_conn = NULL;
if (bec->nc == NULL) {
free(bec);
memset(&conn->backend, 0, sizeof(conn->backend));
return;
}
struct http_backend *be = bec->be;
bec->nc->user_data = bec;
bec->nc->handler = idle_backend_handler;
if (conn->backend.flags.keep_alive) {
bec->idle_deadline = time(NULL) + CONN_IDLE_TIMEOUT;
STAILQ_INSERT_TAIL(&be->conns, bec, conns);
#ifdef DEBUG
write_log("bec=%p becoming idle\n", bec);
#endif
be->num_conns++;
while (be->num_conns > MAX_IDLE_CONNS) {
bec = STAILQ_FIRST(&be->conns);
STAILQ_REMOVE_HEAD(&be->conns, conns);
be->num_conns--;
bec->idle_deadline = 0;
bec->nc->flags = MG_F_CLOSE_IMMEDIATELY;
#ifdef DEBUG
write_log("bec=%p evicted\n", bec);
#endif
}
} else {
bec->idle_deadline = 0;
bec->nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
memset(&conn->backend, 0, sizeof(conn->backend));
}
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct conn_data *conn = (struct conn_data *) nc->user_data;
const time_t now = time(NULL);
#ifdef DEBUG
write_log("%d conn=%p nc=%p ev=%d ev_data=%p bec=%p bec_nc=%p\n", now, conn,
nc, ev, ev_data, conn != NULL ? conn->be_conn : NULL,
conn != NULL && conn->be_conn != NULL ? conn->be_conn->nc : NULL);
#endif
if (conn == NULL) {
if (ev == MG_EV_ACCEPT) {
conn = calloc(1, sizeof(*conn));
if (conn == NULL) {
send_http_err(nc, s_error_500);
} else {
memset(conn, 0, sizeof(*conn));
nc->user_data = conn;
conn->client.nc = nc;
conn->client.body_len = -1;
conn->backend.body_len = -1;
conn->last_activity = now;
}
return;
} else {
if (ev != MG_EV_POLL) {
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
return;
}
}
if (ev != MG_EV_POLL) conn->last_activity = now;
switch (ev) {
case MG_EV_HTTP_REQUEST: { /* From client */
assert(conn != NULL);
assert(conn->be_conn == NULL);
struct http_message *hm = (struct http_message *) ev_data;
conn->client.flags.keep_alive = is_keep_alive(hm);
if (!connect_backend(conn, hm)) {
respond_with_error(conn, s_error_500);
break;
}
if (conn->backend.nc == NULL) {
/* This is a redirect, we're done. */
conn->client.nc->flags |= MG_F_SEND_AND_CLOSE;
break;
}
forward(conn, hm, &conn->client, &conn->backend);
break;
}
case MG_EV_CONNECT: { /* To backend */
assert(conn != NULL);
assert(conn->be_conn != NULL);
int status = *(int *) ev_data;
if (status != 0) {
write_log("Error connecting to %s: %d (%s)\n",
conn->be_conn->be->host_port, status, strerror(status));
/* TODO(lsm): mark backend as defunct, try it later on */
respond_with_error(conn, s_error_500);
conn->be_conn->nc = NULL;
release_backend(conn);
break;
}
break;
}
case MG_EV_HTTP_REPLY: { /* From backend */
assert(conn != NULL);
struct http_message *hm = (struct http_message *) ev_data;
conn->backend.flags.keep_alive = s_backend_keepalive && is_keep_alive(hm);
forward(conn, hm, &conn->backend, &conn->client);
release_backend(conn);
if (!conn->client.flags.keep_alive) {
conn->client.nc->flags |= MG_F_SEND_AND_CLOSE;
} else {
#ifdef DEBUG
write_log("conn=%p remains open\n", conn);
#endif
}
break;
}
case MG_EV_POLL: {
assert(conn != NULL);
if (now - conn->last_activity > CONN_IDLE_TIMEOUT &&
conn->backend.nc == NULL /* not waiting for backend */) {
#ifdef DEBUG
write_log("conn=%p has been idle for too long\n", conn);
conn->client.nc->flags |= MG_F_SEND_AND_CLOSE;
#endif
}
break;
}
case MG_EV_CLOSE: {
assert(conn != NULL);
if (nc == conn->client.nc) {
#ifdef DEBUG
write_log("conn=%p nc=%p client closed, body_sent=%d\n", conn, nc,
conn->backend.body_sent);
#endif
conn->client.nc = NULL;
if (conn->backend.nc != NULL) {
conn->backend.nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
} else if (nc == conn->backend.nc) {
#ifdef DEBUG
write_log("conn=%p nc=%p backend closed\n", conn, nc);
#endif
conn->backend.nc = NULL;
if (conn->client.nc != NULL &&
(conn->backend.body_len < 0 ||
conn->backend.body_sent < conn->backend.body_len)) {
write_log("Backend %s disconnected.\n", conn->be_conn->be->host_port);
respond_with_error(conn, s_error_500);
}
}
if (conn->client.nc == NULL && conn->backend.nc == NULL) {
free(conn);
}
break;
}
}
}
static void print_usage_and_exit(const char *prog_name) {
fprintf(stderr,
"Usage: %s [-D debug_dump_file] [-p http_port] [-l log] [-k]"
#if MG_ENABLE_SSL
"[-s ssl_cert] "
#endif
"<[-r] [-v vhost] -b uri_prefix[=replacement] host_port> ... \n",
prog_name);
exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
struct mg_connection *nc;
int i, redirect = 0;
const char *vhost = NULL;
mg_mgr_init(&mgr, NULL);
/* Parse command line arguments */
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-D") == 0) {
mgr.hexdump_file = argv[i + 1];
i++;
} else if (strcmp(argv[i], "-k") == 0) {
s_backend_keepalive = 1;
} else if (strcmp(argv[i], "-l") == 0 && i + 1 < argc) {
if (strcmp(argv[i + 1], "-") == 0) {
s_log_file = stdout;
} else {
s_log_file = fopen(argv[i + 1], "a");
if (s_log_file == NULL) {
perror("fopen");
exit(EXIT_FAILURE);
}
}
i++;
} else if (strcmp(argv[i], "-p") == 0) {
s_http_port = argv[i + 1];
i++;
} else if (strcmp(argv[i], "-r") == 0 && i + 1 < argc) {
redirect = 1;
} else if (strcmp(argv[i], "-v") == 0 && i + 1 < argc) {
if (strcmp(argv[i + 1], "") == 0) {
vhost = NULL;
} else {
vhost = argv[i + 1];
}
i++;
} else if (strcmp(argv[i], "-b") == 0 && i + 2 < argc) {
struct http_backend *be =
vhost != NULL ? &s_vhost_backends[s_num_vhost_backends++]
: &s_default_backends[s_num_default_backends++];
STAILQ_INIT(&be->conns);
char *r = NULL;
be->vhost = vhost;
be->uri_prefix = argv[i + 1];
be->host_port = argv[i + 2];
be->redirect = redirect;
be->uri_prefix_replacement = be->uri_prefix;
if ((r = strchr(be->uri_prefix, '=')) != NULL) {
*r = '\0';
be->uri_prefix_replacement = r + 1;
}
printf(
"Adding backend for %s%s : %s "
"[redirect=%d,prefix_replacement=%s]\n",
be->vhost == NULL ? "" : be->vhost, be->uri_prefix, be->host_port,
be->redirect, be->uri_prefix_replacement);
vhost = NULL;
redirect = 0;
i += 2;
#ifdef MG_ENABLE_SSL
} else if (strcmp(argv[i], "-s") == 0 && i + 1 < argc) {
s_ssl_cert = argv[++i];
#endif
} else {
print_usage_and_exit(argv[0]);
}
}
/* Open listening socket */
if ((nc = mg_bind(&mgr, s_http_port, ev_handler)) == NULL) {
fprintf(stderr, "mg_bind(%s) failed\n", s_http_port);
exit(EXIT_FAILURE);
}
#if MG_ENABLE_SSL
if (s_ssl_cert != NULL) {
const char *err_str = mg_set_ssl(nc, s_ssl_cert, NULL);
if (err_str != NULL) {
fprintf(stderr, "Error loading SSL cert: %s\n", err_str);
exit(1);
}
}
#endif
mg_set_protocol_http_websocket(nc);
if (s_num_vhost_backends + s_num_default_backends == 0) {
print_usage_and_exit(argv[0]);
}
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
/* Run event loop until signal is received */
printf("Starting LB on port %s\n", s_http_port);
while (s_sig_num == 0) {
mg_mgr_poll(&mgr, 1000);
}
/* Cleanup */
mg_mgr_free(&mgr);
printf("Exiting on signal %d\n", s_sig_num);
return EXIT_SUCCESS;
}
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
PROG=$1
PORT=8002
cleanup() {
kill -9 $PID >/dev/null 2>&1
}
#set -x
trap cleanup EXIT
cleanup
$PROG -p $PORT -b /api/ 127.0.0.1:8000 &
PID=$!
# Perform api_server unit test through the load balancer by passing
# load balancer port to the unit test script
(cd ../api_server && make && sh unit_test.sh ./api_server $PORT)
exit $?
+14
View File
@@ -0,0 +1,14 @@
PROG = mqtt_broker
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -pthread -DMG_ENABLE_SSL -DMG_ENABLE_MQTT_BROKER -lssl -lcrypto $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /DMG_ENABLE_SSL /DMG_ENABLE_MQTT_BROKER /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+43
View File
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
* This software is dual-licensed: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. For the terms of this
* license, see <http://www.gnu.org/licenses/>.
*
* You are free to use this software under the terms of the GNU General
* Public License, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* Alternatively, you can license this software under a commercial
* license, as set out in <https://www.cesanta.com/license>.
*/
#include "../../mongoose.h"
int main(void) {
struct mg_mgr mgr;
const char *address = "0.0.0.0:1883";
struct mg_connection *nc;
struct mg_mqtt_broker brk;
mg_mgr_init(&mgr, NULL);
mg_mqtt_broker_init(&brk, NULL);
if ((nc = mg_bind(&mgr, address, mg_mqtt_broker)) == NULL) {
fprintf(stderr, "mg_bind(%s) failed\n", address);
exit(EXIT_FAILURE);
}
nc->user_data = &brk;
/*
* TODO: Add a HTTP status page that shows current sessions
* and subscriptions
*/
for(;;) {
mg_mgr_poll(&mgr, 1000);
}
}
+14
View File
@@ -0,0 +1,14 @@
PROG = mqtt_client
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -pthread -DMG_ENABLE_SSL -lssl -lcrypto $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /DMG_ENABLE_SSL /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+86
View File
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
* This software is dual-licensed: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. For the terms of this
* license, see <http://www.gnu.org/licenses/>.
*
* You are free to use this software under the terms of the GNU General
* Public License, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* Alternatively, you can license this software under a commercial
* license, as set out in <https://www.cesanta.com/license>.
*/
#include "mongoose.h"
struct mg_mqtt_topic_expression topic_expressions[] = {
{"/stuff", 0}
};
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
struct mg_mqtt_message *msg = (struct mg_mqtt_message *)p;
(void) nc;
#if 0
if (ev != MG_EV_POLL)
printf("USER HANDLER GOT %d\n", ev);
#endif
switch (ev) {
case MG_EV_CONNECT:
mg_set_protocol_mqtt(nc);
mg_send_mqtt_handshake(nc, "dummy");
break;
case MG_EV_MQTT_CONNACK:
if (msg->connack_ret_code != MG_EV_MQTT_CONNACK_ACCEPTED) {
printf("Got mqtt connection error: %d\n", msg->connack_ret_code);
exit(1);
}
printf("Subscribing to '/stuff'\n");
mg_mqtt_subscribe(nc, topic_expressions, sizeof(topic_expressions)/sizeof(*topic_expressions), 42);
break;
case MG_EV_MQTT_PUBACK:
printf("Message publishing acknowledged (msg_id: %d)\n", msg->message_id);
break;
case MG_EV_MQTT_SUBACK:
printf("Subscription acknowledged, forwarding to '/test'\n");
break;
case MG_EV_MQTT_PUBLISH:
{
#if 0
char hex[1024] = {0};
mg_hexdump(nc->recv_mbuf.buf, msg->payload.len, hex, sizeof(hex));
printf("Got incoming message %s:\n%s", msg->topic, hex);
#else
printf("Got incoming message %s: %.*s\n", msg->topic, (int)msg->payload.len, msg->payload.p);
#endif
printf("Forwarding to /test\n");
mg_mqtt_publish(nc, "/test", 65, MG_MQTT_QOS(0), msg->payload.p, msg->payload.len);
}
break;
case MG_EV_CLOSE:
printf("Connection closed\n");
exit(1);
}
}
int main(void) {
struct mg_mgr mgr;
const char *address = "localhost:1883";
mg_mgr_init(&mgr, NULL);
if (mg_connect(&mgr, address, ev_handler) == NULL) {
fprintf(stderr, "mg_connect(%s) failed\n", address);
exit(EXIT_FAILURE);
}
for(;;) {
mg_mgr_poll(&mgr, 1000);
}
}
@@ -0,0 +1,18 @@
PROG = multithreaded_restful_server
SOURCES = $(PROG).c ../../mongoose.c
APP_FLAGS = -DMG_ENABLE_THREADS $(CFLAGS_EXTRA)
ifeq ($(OS), Windows_NT)
APP_FLAGS += advapi32.lib
endif
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ -W -Wall -I../.. -pthread $(APP_FLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@ $(APP_FLAGS)
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
@@ -0,0 +1,52 @@
// Copyright (c) 2015 Cesanta Software Limited
// All rights reserved
// This example shows how to handle long, blocking requests by
// handing off computation to different threads. Here, each
// request spawns a new thread. In a production scenario, a thread
// pools can be used for efficiency, if required.
// Long computation is simulated by sleeping for a random interval.
#include "mongoose.h"
static const char *s_http_port = "8000";
static void ev_handler(struct mg_connection *c, int ev, void *p) {
if (ev == MG_EV_HTTP_REQUEST) {
struct http_message *hm = (struct http_message *) p;
char reply[100];
/* Simulate long calculation */
sleep(3);
/* Send the reply */
snprintf(reply, sizeof(reply), "{ \"uri\": \"%.*s\" }\n",
(int) hm->uri.len, hm->uri.p);
mg_printf(c, "HTTP/1.1 200 OK\r\n"
"Content-Type: application/json\r\n"
"Content-Length: %d\r\n"
"\r\n"
"%s",
(int) strlen(reply), reply);
}
}
int main(void) {
struct mg_mgr mgr;
struct mg_connection *nc;
mg_mgr_init(&mgr, NULL);
nc = mg_bind(&mgr, s_http_port, ev_handler);
mg_set_protocol_http_websocket(nc);
/* For each new connection, execute ev_handler in a separate thread */
mg_enable_multithreading(nc);
printf("Starting multi-threaded server on port %s\n", s_http_port);
for (;;) {
mg_mgr_poll(&mgr, 3000);
}
mg_mgr_free(&mgr);
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
PROG = nc
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -pthread -DMG_ENABLE_SSL -DMG_ENABLE_THREADS -lssl -lcrypto $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /DMG_ENABLE_SSL /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
+140
View File
@@ -0,0 +1,140 @@
// Copyright (c) 2014 Cesanta Software Limited
// All rights reserved
//
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. For the terms of this
// license, see <http://www.gnu.org/licenses/>.
//
// You are free to use this software under the terms of the GNU General
// Public License, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// Alternatively, you can license this software under a commercial
// license, as set out in <https://www.cesanta.com/license>.
//
// $Date: 2014-09-28 05:04:41 UTC $
// This file implements "netcat" utility with SSL and traffic hexdump.
#include "mongoose.h"
static sig_atomic_t s_received_signal = 0;
static void signal_handler(int sig_num) {
signal(sig_num, signal_handler);
s_received_signal = sig_num;
}
static void show_usage_and_exit(const char *prog_name) {
fprintf(stderr, "%s\n", "Copyright (c) 2014 CESANTA SOFTWARE");
fprintf(stderr, "%s\n", "Usage:");
fprintf(stderr, " %s\n [-d debug_file] [-l] [tcp|ssl]://[ip:]port[:cert][:ca_cert]",
prog_name);
fprintf(stderr, "%s\n", "Examples:");
fprintf(stderr, " %s\n -d hexdump.txt ssl://google.com:443", prog_name);
fprintf(stderr, " %s\n -l ssl://443:ssl_cert.pem", prog_name);
fprintf(stderr, " %s\n -l tcp://8080", prog_name);
exit(EXIT_FAILURE);
}
static void on_stdin_read(struct mg_connection *nc, int ev, void *p) {
int ch = * (int *) p;
(void) ev;
if (ch < 0) {
// EOF is received from stdin. Schedule the connection to close
nc->flags |= MG_F_SEND_AND_CLOSE;
if (nc->send_mbuf.len <= 0) {
nc->flags |= MG_F_CLOSE_IMMEDIATELY;
}
} else {
// A character is received from stdin. Send it to the connection.
unsigned char c = (unsigned char) ch;
mg_send(nc, &c, 1);
}
}
static void *stdio_thread_func(void *param) {
struct mg_mgr *mgr = (struct mg_mgr *) param;
int ch;
// Read stdin until EOF character by character, sending them to the mgr
while ((ch = getchar()) != EOF) {
mg_broadcast(mgr, on_stdin_read, &ch, sizeof(ch));
}
s_received_signal = 1;
return NULL;
}
static void ev_handler(struct mg_connection *nc, int ev, void *p) {
(void) p;
switch (ev) {
case MG_EV_ACCEPT:
case MG_EV_CONNECT:
mg_start_thread(stdio_thread_func, nc->mgr);
break;
case MG_EV_CLOSE:
s_received_signal = 1;
break;
case MG_EV_RECV:
fwrite(nc->recv_mbuf.buf, 1, nc->recv_mbuf.len, stdout);
mbuf_remove(&nc->recv_mbuf, nc->recv_mbuf.len);
break;
default:
break;
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
int i, is_listening = 0;
const char *address = NULL;
mg_mgr_init(&mgr, NULL);
// Parse command line options
for (i = 1; i < argc && argv[i][0] == '-'; i++) {
if (strcmp(argv[i], "-l") == 0) {
is_listening = 1;
} else if (strcmp(argv[i], "-d") == 0 && i + 1 < argc) {
mgr.hexdump_file = argv[++i];
} else {
show_usage_and_exit(argv[0]);
}
}
if (i + 1 == argc) {
address = argv[i];
} else {
show_usage_and_exit(argv[0]);
}
signal(SIGTERM, signal_handler);
signal(SIGINT, signal_handler);
signal(SIGPIPE, SIG_IGN);
if (is_listening) {
if (mg_bind(&mgr, address, ev_handler) == NULL) {
fprintf(stderr, "mg_bind(%s) failed\n", address);
exit(EXIT_FAILURE);
}
} else if (mg_connect(&mgr, address, ev_handler) == NULL) {
fprintf(stderr, "mg_connect(%s) failed\n", address);
exit(EXIT_FAILURE);
}
while (s_received_signal == 0) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return EXIT_SUCCESS;
}
+14
View File
@@ -0,0 +1,14 @@
PROG = publish_subscribe
SOURCES = $(PROG).c ../../mongoose.c
CFLAGS = -W -Wall -I../.. -DMG_ENABLE_THREADS -pthread $(CFLAGS_EXTRA)
all: $(PROG)
$(PROG): $(SOURCES)
$(CC) $(SOURCES) -o $@ $(CFLAGS)
$(PROG).exe: $(SOURCES)
cl $(SOURCES) /I../.. /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROG)
@@ -0,0 +1,112 @@
// Copyright (c) 2014 Cesanta Software Limited
// All rights reserved
//
// This software is dual-licensed: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation. For the terms of this
// license, see <http://www.gnu.org/licenses/>.
//
// You are free to use this software under the terms of the GNU General
// Public License, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// Alternatively, you can license this software under a commercial
// license, as set out in <https://www.cesanta.com/license>.
//
// $Date: 2014-09-28 05:04:41 UTC $
#include "mongoose.h"
static void *stdin_thread(void *param) {
int ch, sock = * (int *) param;
while ((ch = getchar()) != EOF) {
unsigned char c = (unsigned char) ch;
send(sock, &c, 1, 0); // Forward all types characters to the socketpair
}
return NULL;
}
static void server_handler(struct mg_connection *nc, int ev, void *p) {
(void) p;
if (ev == MG_EV_RECV) {
// Push received message to all ncections
struct mbuf *io = &nc->recv_mbuf;
struct mg_connection *c;
for (c = mg_next(nc->mgr, NULL); c != NULL; c = mg_next(nc->mgr, c)) {
mg_send(c, io->buf, io->len);
}
mbuf_remove(io, io->len);
}
}
static void client_handler(struct mg_connection *conn, int ev, void *p) {
struct mbuf *io = &conn->recv_mbuf;
(void) p;
if (ev == MG_EV_CONNECT) {
if (conn->flags & MG_F_CLOSE_IMMEDIATELY) {
printf("%s\n", "Error connecting to server!");
exit(EXIT_FAILURE);
}
printf("%s\n", "Connected to server. Type a message and press enter.");
} else if (ev == MG_EV_RECV) {
if (conn->flags & MG_F_USER_1) {
// Received data from the stdin, forward it to the server
struct mg_connection *c = (struct mg_connection *) conn->user_data;
mg_send(c, io->buf, io->len);
mbuf_remove(io, io->len);
} else {
// Received data from server connection, print it
fwrite(io->buf, io->len, 1, stdout);
mbuf_remove(io, io->len);
}
} else if (ev == MG_EV_CLOSE) {
// Connection has closed, most probably cause server has stopped
exit(EXIT_SUCCESS);
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
if (argc != 3) {
fprintf(stderr, "Usage: %s <port> <client|server>\n", argv[0]);
exit(EXIT_FAILURE);
} else if (strcmp(argv[2], "client") == 0) {
int fds[2];
struct mg_connection *ioconn, *server_conn;
mg_mgr_init(&mgr, NULL);
// Connect to the pubsub server
server_conn = mg_connect(&mgr, argv[1], client_handler);
if (server_conn == NULL) {
fprintf(stderr, "Cannot connect to port %s\n", argv[1]);
exit(EXIT_FAILURE);
}
// Create a socketpair and give one end to the thread that reads stdin
mg_socketpair(fds, SOCK_STREAM);
mg_start_thread(stdin_thread, &fds[1]);
// The other end of a pair goes inside the server
ioconn = mg_add_sock(&mgr, fds[0], client_handler);
ioconn->flags |= MG_F_USER_1; // Mark this so we know this is a stdin
ioconn->user_data = server_conn;
} else {
// Server code path
mg_mgr_init(&mgr, NULL);
mg_bind(&mgr, argv[1], server_handler);
printf("Starting pubsub server on port %s\n", argv[1]);
}
for (;;) {
mg_mgr_poll(&mgr, 1000);
}
mg_mgr_free(&mgr);
return EXIT_SUCCESS;
}
+18
View File
@@ -0,0 +1,18 @@
NS=../../mongoose.c
FLAGS = ../../mongoose.c -I../..
CFLAGS=-W -Wall -DMG_ENABLE_THREADS -pthread $(CFLAGS_EXTRA)
PROGS = device_side cloud_side
all: $(PROGS)
device_side: Makefile device_side.c $(NS)
$(CC) device_side.c $(FLAGS) -o $@ $(CFLAGS)
cloud_side: Makefile cloud_side.c $(NS)
$(CC) cloud_side.c $(FLAGS) -o $@ $(CFLAGS)
device_side.exe: Makefile device_side.c $(NS)
cl device_side.c $(FLAGS) /MD /Fe$@
clean:
rm -rf *.gc* *.dSYM *.exe *.obj *.o a.out $(PROGS)
@@ -0,0 +1,72 @@
= Raspberry Pi camera/LED demo
== Overview
The link:/[demo] consists of web app providing access to a webcam and a LED attached to a RaspberryPi.
The device is assumed to have a limited bandwidth towards the server hosting the web app.
== Objective
The demo shows how to use websockets to communicate bidirectionally with an embedded device using standard protocols.
It also shows that it's possible to use Smart.c to develop also the cloud endpoint and expose WebSocket and RESTful APIs
easy to integreate with modern web stacks.
== How it works
image::docs/arch.png[]
There are two components, once with runs on the device (`device_side`) and one that runs on a stronger machine
and with more bandwidth (`cloud_side`).
The device app connects to the cloud app via websocket and sends a new jpeg frame as fast as the underlying `raspistill` camera
grabbing application can handle. The device automatically attempts reconnecting.
The cloud side serves the webapp static pages and serves an MPJEG image on `/mpjg`.
The MPJEG image handler blocks all the clients until a JPEG frame arrives via websocket
and then every client will receive a copy of the frame.
The web app can turn on and off the LED via a RESTful api accessible via the `/api` handler.
== Installation
=== Server side
----
git clone https://github.com/cesanta/mongoose
cd mongoose/examples/web_demo
make cloud_side && ./cloud_side 0.0.0.0:8080
----
=== Raspberry Pi
The instructions provided here are tailored for the Raspbian distribution.
==== Dependencies
jpegoptim::
apt-get install jpegoptim
camera::
run raspi-config and enable camera
==== LED
In order to access the led on your link:http://www.qdh.org.uk/wordpress/?page_id=15[HotPi]
board you need to export the gpio pins:
----
for i in 22 23 24; do
echo $i >/sys/class/gpio/export
echo out >/sys/class/gpio/gpio$i/direction
chgrp pi /sys/class/gpio/gpio$i/value
done
----
==== Build and run
----
git clone https://github.com/cesanta/mongoose
cd mongoose/examples/web_demo
make device_side && ./device_side yourserver:8080
----
@@ -0,0 +1,143 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/
/*
* This is the cloud endpoint of the Raspberry Pi camera/LED example
* of the Mongoose networking library.
* It is a simple web server, serving both static files, a REST API handler,
* and a WebSocket handler.
*/
#include "mongoose.h"
static struct mg_serve_http_opts web_root_opts;
/*
* Forwards the jpeg frame data to all open mjpeg connections.
*
* Incoming messages follow a very simple binary frame format:
* 4 bytes: timestamp (in network byte order)
* n bytes: jpeg payload
*
* The timestamp is used to compute a lag.
* It's done in a quite stupid way as it requires the device clock
* to be synchronized with the cloud endpoint.
*/
static void push_frame_to_clients(struct mg_mgr *mgr,
const struct websocket_message *wm) {
struct mg_connection *nc;
/*
* mjpeg connections are tagged with the MG_F_USER_2 flag so we can find them
* my scanning the connection list provided by the mongoose manager.
*/
for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) {
if (!(nc->flags & MG_F_USER_2)) continue; // Ignore un-marked requests
mg_printf(nc, "--w00t\r\nContent-Type: image/jpeg\r\n"
"Content-Length: %lu\r\n\r\n", (unsigned long) wm->size);
mg_send(nc, wm->data, wm->size);
mg_send(nc, "\r\n", 2);
printf("Image pushed to %p\n", nc);
}
}
/*
* Forwards API payload to the device, by scanning through
* all the connections to find those that are tagged as WebSocket.
*/
static void send_command_to_the_device(struct mg_mgr *mgr,
const struct mg_str *cmd) {
struct mg_connection *nc;
for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) {
if (!(nc->flags & MG_F_IS_WEBSOCKET)) continue; // Ignore non-websocket requests
mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, cmd->p, cmd->len);
printf("Sent API command [%.*s] to %p\n", (int) cmd->len, cmd->p, nc);
}
}
/*
* Main event handler. Receives data events and dispatches to
* the appropriate handler function.
*
* 1. RESTful API requests are handled by send_command_to_the_device.
* 2. requests to /mpeg are established and left open waiting for data to arrive
* from WebSocket.
* 3. WebSocket frames are handled by push_frame_to_clients.
* 4. All other connections are passed to the mg_serve_http handler
* which serves static files.
*/
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
struct websocket_message *wm = (struct websocket_message *) ev_data;
struct http_message *hm = (struct http_message *) ev_data;
switch (ev) {
case MG_EV_HTTP_REQUEST:
if (mg_vcmp(&hm->uri, "/mjpg") == 0) {
nc->flags |= MG_F_USER_2; /* Set a mark on image requests */
mg_printf(nc, "%s",
"HTTP/1.0 200 OK\r\n"
"Cache-Control: no-cache\r\n"
"Pragma: no-cache\r\n"
"Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n"
"Connection: close\r\n"
"Content-Type: multipart/x-mixed-replace; "
"boundary=--w00t\r\n\r\n");
} else if (mg_vcmp(&hm->uri, "/api") == 0 && hm->body.len > 0) {
/*
* RESTful API call. HTTP message body should be a JSON message.
* We should parse it and take appropriate action.
* In our case, simply forward that call to the device.
*/
printf("API CALL: [%.*s] [%.*s]\n", (int) hm->method.len, hm->method.p,
(int) hm->body.len, hm->body.p);
send_command_to_the_device(nc->mgr, &hm->body);
mg_printf(nc, "HTTP/1.0 200 OK\nContent-Length: 0\n\n");
} else {
/* Delegate to the static web server handler for all other paths. */
mg_serve_http(nc, hm, web_root_opts);
}
break;
case MG_EV_WEBSOCKET_FRAME:
printf("Got websocket frame, size %lu\n", (unsigned long) wm->size);
push_frame_to_clients(nc->mgr, wm);
break;
}
}
int main(int argc, char *argv[]) {
struct mg_mgr mgr;
struct mg_connection *nc;
if (argc != 2) {
fprintf(stderr, "Usage: %s <listening_addr>\n", argv[0]);
exit(EXIT_FAILURE);
}
printf("Listening on: [%s]\n", argv[1]);
mg_mgr_init(&mgr, NULL);
/*
* mg_bind() creates a listening connection on a given ip:port and
* with an attached event handler.
* The event handler will only trigger TCP events until the http
* protocol handler is installed.
*/
if ((nc = mg_bind(&mgr, argv[1], ev_handler)) == NULL) {
fprintf(stderr, "Error binding to %s\n", argv[1]);
exit(EXIT_FAILURE);
}
mg_set_protocol_http_websocket(nc);
web_root_opts.document_root = "./web_root";
/*
* We explicitly hand over control to the Mongoose manager
* in this event loop and we can easily multiplex other activities.
*/
for(;;) {
mg_mgr_poll(&mgr, 1000);
}
return EXIT_SUCCESS;
}
Loaded 100 of 165 files, more files were not shown because too many files have changed in this diff. Show more