Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 1-wire clock crypto fram log lpc1768 net web wiz mbed
web-this/web-server-this.c@0:22b158d3c76f, 2021-05-10 (annotated)
- Committer:
- andrewboyson
- Date:
- Mon May 10 10:23:48 2021 +0000
- Revision:
- 0:22b158d3c76f
New version as old one would not commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 0:22b158d3c76f | 1 | #include "http.h" |
| andrewboyson | 0:22b158d3c76f | 2 | #include "web-pages-this.h" |
| andrewboyson | 0:22b158d3c76f | 3 | #include "web.h" |
| andrewboyson | 0:22b158d3c76f | 4 | |
| andrewboyson | 0:22b158d3c76f | 5 | #define DO_HOME_HTML DO_THIS + 0 |
| andrewboyson | 0:22b158d3c76f | 6 | #define DO_PROGRAM_HTML DO_THIS + 1 |
| andrewboyson | 0:22b158d3c76f | 7 | #define DO_PROGRAM_AJAX DO_THIS + 2 |
| andrewboyson | 0:22b158d3c76f | 8 | #define DO_PROGRAM_SCRIPT DO_THIS + 3 |
| andrewboyson | 0:22b158d3c76f | 9 | #define DO_RADIATOR_HTML DO_THIS + 4 |
| andrewboyson | 0:22b158d3c76f | 10 | #define DO_RADIATOR_AJAX DO_THIS + 5 |
| andrewboyson | 0:22b158d3c76f | 11 | #define DO_RADIATOR_SCRIPT DO_THIS + 6 |
| andrewboyson | 0:22b158d3c76f | 12 | #define DO_BOILER_HTML DO_THIS + 7 |
| andrewboyson | 0:22b158d3c76f | 13 | #define DO_BOILER_AJAX DO_THIS + 8 |
| andrewboyson | 0:22b158d3c76f | 14 | #define DO_BOILER_SCRIPT DO_THIS + 9 |
| andrewboyson | 0:22b158d3c76f | 15 | #define DO_SYSTEM_HTML DO_THIS + 10 |
| andrewboyson | 0:22b158d3c76f | 16 | #define DO_SYSTEM_AJAX DO_THIS + 11 |
| andrewboyson | 0:22b158d3c76f | 17 | #define DO_SYSTEM_SCRIPT DO_THIS + 12 |
| andrewboyson | 0:22b158d3c76f | 18 | #define DO_1WIRE_HTML DO_THIS + 13 |
| andrewboyson | 0:22b158d3c76f | 19 | #define DO_1WIRE_AJAX DO_THIS + 14 |
| andrewboyson | 0:22b158d3c76f | 20 | #define DO_1WIRE_SCRIPT DO_THIS + 15 |
| andrewboyson | 0:22b158d3c76f | 21 | #define DO_WIZ_HTML DO_THIS + 16 |
| andrewboyson | 0:22b158d3c76f | 22 | #define DO_WIZ_AJAX DO_THIS + 17 |
| andrewboyson | 0:22b158d3c76f | 23 | #define DO_WIZ_SCRIPT DO_THIS + 18 |
| andrewboyson | 0:22b158d3c76f | 24 | |
| andrewboyson | 0:22b158d3c76f | 25 | int WebServerThisDecideWhatToDo(char *pPath, char* pLastModified) |
| andrewboyson | 0:22b158d3c76f | 26 | { |
| andrewboyson | 0:22b158d3c76f | 27 | if (HttpSameStr(pPath, "/" )) return DO_HOME_HTML; |
| andrewboyson | 0:22b158d3c76f | 28 | if (HttpSameStr(pPath, "/program" )) return DO_PROGRAM_HTML; |
| andrewboyson | 0:22b158d3c76f | 29 | if (HttpSameStr(pPath, "/program-ajax" )) return DO_PROGRAM_AJAX; |
| andrewboyson | 0:22b158d3c76f | 30 | if (HttpSameStr(pPath, "/radiator" )) return DO_RADIATOR_HTML; |
| andrewboyson | 0:22b158d3c76f | 31 | if (HttpSameStr(pPath, "/radiator-ajax")) return DO_RADIATOR_AJAX; |
| andrewboyson | 0:22b158d3c76f | 32 | if (HttpSameStr(pPath, "/boiler" )) return DO_BOILER_HTML; |
| andrewboyson | 0:22b158d3c76f | 33 | if (HttpSameStr(pPath, "/boiler-ajax" )) return DO_BOILER_AJAX; |
| andrewboyson | 0:22b158d3c76f | 34 | if (HttpSameStr(pPath, "/system" )) return DO_SYSTEM_HTML; |
| andrewboyson | 0:22b158d3c76f | 35 | if (HttpSameStr(pPath, "/system-ajax" )) return DO_SYSTEM_AJAX; |
| andrewboyson | 0:22b158d3c76f | 36 | if (HttpSameStr(pPath, "/1wire" )) return DO_1WIRE_HTML; |
| andrewboyson | 0:22b158d3c76f | 37 | if (HttpSameStr(pPath, "/1wire-ajax" )) return DO_1WIRE_AJAX; |
| andrewboyson | 0:22b158d3c76f | 38 | if (HttpSameStr(pPath, "/wiz" )) return DO_WIZ_HTML; |
| andrewboyson | 0:22b158d3c76f | 39 | if (HttpSameStr(pPath, "/wiz-ajax" )) return DO_WIZ_AJAX; |
| andrewboyson | 0:22b158d3c76f | 40 | |
| andrewboyson | 0:22b158d3c76f | 41 | if (HttpSameStr(pPath, "/program.js" )) return HttpSameDate(WebProgramScriptDate, WebProgramScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_PROGRAM_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 42 | if (HttpSameStr(pPath, "/radiator.js" )) return HttpSameDate(WebRadiatorScriptDate, WebRadiatorScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_RADIATOR_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 43 | if (HttpSameStr(pPath, "/boiler.js" )) return HttpSameDate(WebBoilerScriptDate, WebBoilerScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_BOILER_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 44 | if (HttpSameStr(pPath, "/system.js" )) return HttpSameDate(WebSystemScriptDate, WebSystemScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_SYSTEM_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 45 | if (HttpSameStr(pPath, "/1wire.js" )) return HttpSameDate(WebOneWireScriptDate, WebOneWireScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_1WIRE_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 46 | if (HttpSameStr(pPath, "/wiz.js" )) return HttpSameDate(WebWizScriptDate, WebWizScriptTime, pLastModified) ? DO_NOT_MODIFIED : DO_WIZ_SCRIPT; |
| andrewboyson | 0:22b158d3c76f | 47 | |
| andrewboyson | 0:22b158d3c76f | 48 | return DO_NOT_FOUND; |
| andrewboyson | 0:22b158d3c76f | 49 | } |
| andrewboyson | 0:22b158d3c76f | 50 | |
| andrewboyson | 0:22b158d3c76f | 51 | bool WebServerThisHandleQuery(int todo, char* pQuery) |
| andrewboyson | 0:22b158d3c76f | 52 | { |
| andrewboyson | 0:22b158d3c76f | 53 | switch (todo) |
| andrewboyson | 0:22b158d3c76f | 54 | { |
| andrewboyson | 0:22b158d3c76f | 55 | case DO_PROGRAM_AJAX: WebProgramQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 56 | case DO_PROGRAM_HTML: WebProgramQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 57 | case DO_RADIATOR_HTML: WebRadiatorQuery(pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 58 | case DO_RADIATOR_AJAX: WebRadiatorQuery(pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 59 | case DO_BOILER_HTML: WebBoilerQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 60 | case DO_BOILER_AJAX: WebBoilerQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 61 | case DO_SYSTEM_HTML: WebSystemQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 62 | case DO_SYSTEM_AJAX: WebSystemQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 63 | case DO_1WIRE_HTML: WebOneWireQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 64 | case DO_1WIRE_AJAX: WebOneWireQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 65 | case DO_WIZ_HTML: WebWizQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 66 | case DO_WIZ_AJAX: WebWizQuery (pQuery); return true; |
| andrewboyson | 0:22b158d3c76f | 67 | } |
| andrewboyson | 0:22b158d3c76f | 68 | return false; |
| andrewboyson | 0:22b158d3c76f | 69 | } |
| andrewboyson | 0:22b158d3c76f | 70 | bool WebServerThisPost(int todo, int contentLength, int contentStart, int size, char* pRequestStream, uint32_t positionInRequestStream, bool* pComplete) |
| andrewboyson | 0:22b158d3c76f | 71 | { |
| andrewboyson | 0:22b158d3c76f | 72 | return false; |
| andrewboyson | 0:22b158d3c76f | 73 | } |
| andrewboyson | 0:22b158d3c76f | 74 | bool WebServerThisReply(int todo) |
| andrewboyson | 0:22b158d3c76f | 75 | { |
| andrewboyson | 0:22b158d3c76f | 76 | switch (todo) |
| andrewboyson | 0:22b158d3c76f | 77 | { |
| andrewboyson | 0:22b158d3c76f | 78 | case DO_HOME_HTML: WebHomeHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 79 | case DO_PROGRAM_HTML: WebProgramHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 80 | case DO_PROGRAM_AJAX: WebProgramAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 81 | case DO_PROGRAM_SCRIPT: WebProgramScript (); return true; |
| andrewboyson | 0:22b158d3c76f | 82 | case DO_RADIATOR_HTML: WebRadiatorHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 83 | case DO_RADIATOR_AJAX: WebRadiatorAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 84 | case DO_RADIATOR_SCRIPT: WebRadiatorScript(); return true; |
| andrewboyson | 0:22b158d3c76f | 85 | case DO_BOILER_HTML: WebBoilerHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 86 | case DO_BOILER_AJAX: WebBoilerAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 87 | case DO_BOILER_SCRIPT: WebBoilerScript (); return true; |
| andrewboyson | 0:22b158d3c76f | 88 | case DO_SYSTEM_HTML: WebSystemHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 89 | case DO_SYSTEM_AJAX: WebSystemAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 90 | case DO_SYSTEM_SCRIPT: WebSystemScript (); return true; |
| andrewboyson | 0:22b158d3c76f | 91 | case DO_1WIRE_HTML: WebOneWireHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 92 | case DO_1WIRE_AJAX: WebOneWireAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 93 | case DO_1WIRE_SCRIPT: WebOneWireScript (); return true; |
| andrewboyson | 0:22b158d3c76f | 94 | case DO_WIZ_HTML: WebWizHtml (); return true; |
| andrewboyson | 0:22b158d3c76f | 95 | case DO_WIZ_AJAX: WebWizAjax (); return true; |
| andrewboyson | 0:22b158d3c76f | 96 | case DO_WIZ_SCRIPT: WebWizScript (); return true; |
| andrewboyson | 0:22b158d3c76f | 97 | } |
| andrewboyson | 0:22b158d3c76f | 98 | return false; |
| andrewboyson | 0:22b158d3c76f | 99 | } |