Fix big-data crash (Civetweb Issue)

- For same reason, data over 97.6Kb (100000 bytes) may have data loss because of Civetweb has an issue. That's make the webui-protocol-header had incorrect data size so it crashes (over flow) if user access the most significant byte. However, WebUI won't crash now. But we should report this to Civetweb.
This commit is contained in:
Hassan DRAGA 2023-10-07 15:35:45 -04:00
parent 61a92b0da1
commit 9a78898d62
7 changed files with 367 additions and 265 deletions

View File

@ -1593,211 +1593,210 @@ unsigned char webui_javascript_bridge[] = {
0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x73, 0x29, 0x2c, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x2e, 0x2e, 0x2e, 0x61, 0x72,
0x67, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x2c, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x74,
0x68, 0x69, 0x73, 0x2e, 0x23, 0x61, 0x64, 0x64, 0x54, 0x6f,
0x6b, 0x65, 0x6e, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f,
0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x61, 0x64,
0x64, 0x49, 0x44, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x2c, 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x2c, 0x20,
0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x50, 0x52, 0x4f, 0x54,
0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x49, 0x44, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x6e, 0x65, 0x77, 0x20, 0x50, 0x72, 0x6f, 0x6d, 0x69,
0x73, 0x65, 0x28, 0x28, 0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76,
0x65, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23,
0x63, 0x61, 0x6c, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69, 0x73,
0x65, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x5b, 0x63,
0x61, 0x6c, 0x6c, 0x49, 0x64, 0x5d, 0x20, 0x3d, 0x20, 0x72,
0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23,
0x50, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x73, 0x2e, 0x73,
0x65, 0x6e, 0x64, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74,
0x2e, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x7d, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d, 0x20,
0x41, 0x50, 0x49, 0x73, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x67, 0x73, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x61, 0x64, 0x64, 0x54,
0x6f, 0x6b, 0x65, 0x6e, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x74,
0x6f, 0x6b, 0x65, 0x6e, 0x2c, 0x20, 0x74, 0x68, 0x69, 0x73,
0x2e, 0x23, 0x50, 0x52, 0x4f, 0x54, 0x4f, 0x43, 0x4f, 0x4c,
0x5f, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x61,
0x64, 0x64, 0x49, 0x44, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x2c, 0x20, 0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x2c,
0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x50, 0x52, 0x4f,
0x54, 0x4f, 0x43, 0x4f, 0x4c, 0x5f, 0x49, 0x44, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
0x6e, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x50, 0x72, 0x6f, 0x6d,
0x69, 0x73, 0x65, 0x28, 0x28, 0x72, 0x65, 0x73, 0x6f, 0x6c,
0x76, 0x65, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x63, 0x61, 0x6c, 0x6c, 0x50, 0x72, 0x6f, 0x6d, 0x69,
0x73, 0x65, 0x52, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x5b,
0x63, 0x61, 0x6c, 0x6c, 0x49, 0x64, 0x5d, 0x20, 0x3d, 0x20,
0x72, 0x65, 0x73, 0x6f, 0x6c, 0x76, 0x65, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x50, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x66, 0x61,
0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x73, 0x2e,
0x73, 0x65, 0x6e, 0x64, 0x28, 0x70, 0x61, 0x63, 0x6b, 0x65,
0x74, 0x2e, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x7d, 0x0a, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x2d, 0x2d,
0x20, 0x41, 0x50, 0x49, 0x73, 0x20, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x0a, 0x20, 0x20, 0x2f, 0x2a, 0x2a, 0x0a, 0x20, 0x20,
0x2a, 0x20, 0x43, 0x61, 0x6c, 0x6c, 0x20, 0x61, 0x20, 0x62,
0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20, 0x66, 0x75, 0x6e,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2a, 0x20,
0x2d, 0x2d, 0x0a, 0x20, 0x20, 0x2f, 0x2a, 0x2a, 0x0a, 0x20,
0x20, 0x2a, 0x20, 0x43, 0x61, 0x6c, 0x6c, 0x20, 0x61, 0x20,
0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20, 0x66, 0x75,
0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20, 0x2a,
0x20, 0x0a, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x70, 0x61, 0x72,
0x61, 0x6d, 0x20, 0x66, 0x6e, 0x20, 0x2d, 0x20, 0x62, 0x69,
0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65,
0x0a, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x70, 0x61, 0x72, 0x61,
0x6d, 0x20, 0x66, 0x6e, 0x20, 0x2d, 0x20, 0x62, 0x69, 0x6e,
0x64, 0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x0a,
0x20, 0x20, 0x2a, 0x20, 0x40, 0x70, 0x61, 0x72, 0x61, 0x6d,
0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x2d, 0x20, 0x64, 0x61,
0x74, 0x61, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x73,
0x65, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65,
0x20, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20, 0x66,
0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20, 0x20,
0x2a, 0x20, 0x40, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x2d, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x61,
0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20, 0x63, 0x61, 0x6c, 0x6c,
0x62, 0x61, 0x63, 0x6b, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e,
0x67, 0x0a, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x65, 0x78, 0x61,
0x6d, 0x70, 0x6c, 0x65, 0x20, 0x2d, 0x20, 0x63, 0x6f, 0x6e,
0x73, 0x74, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x61,
0x77, 0x61, 0x69, 0x74, 0x20, 0x77, 0x65, 0x62, 0x75, 0x69,
0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x22, 0x6d, 0x79, 0x49,
0x44, 0x22, 0x2c, 0x20, 0x31, 0x32, 0x33, 0x2c, 0x20, 0x74,
0x72, 0x75, 0x65, 0x2c, 0x20, 0x22, 0x48, 0x69, 0x22, 0x2c,
0x20, 0x6e, 0x65, 0x77, 0x20, 0x55, 0x69, 0x6e, 0x74, 0x38,
0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x5b, 0x30, 0x78, 0x34,
0x32, 0x2c, 0x20, 0x30, 0x78, 0x34, 0x33, 0x2c, 0x20, 0x30,
0x78, 0x34, 0x34, 0x5d, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x2a,
0x2f, 0x0a, 0x20, 0x20, 0x61, 0x73, 0x79, 0x6e, 0x63, 0x20,
0x63, 0x61, 0x6c, 0x6c, 0x28, 0x66, 0x6e, 0x2c, 0x20, 0x2e,
0x2e, 0x2e, 0x61, 0x72, 0x67, 0x73, 0x29, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x66,
0x6e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x50, 0x72, 0x6f, 0x6d,
0x69, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74,
0x28, 0x6e, 0x65, 0x77, 0x20, 0x53, 0x79, 0x6e, 0x74, 0x61,
0x78, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x22, 0x4e, 0x6f,
0x20, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6e,
0x61, 0x6d, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f,
0x76, 0x69, 0x64, 0x65, 0x64, 0x22, 0x29, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21, 0x74,
0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x73, 0x53, 0x74, 0x61,
0x74, 0x75, 0x73, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x50, 0x72,
0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6a, 0x65,
0x63, 0x74, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x45, 0x72, 0x72,
0x6f, 0x72, 0x28, 0x22, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63,
0x6b, 0x65, 0x74, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f, 0x74,
0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65, 0x64,
0x22, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
0x66, 0x20, 0x28, 0x21, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23,
0x68, 0x61, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x20,
0x26, 0x26, 0x20, 0x21, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23,
0x62, 0x69, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x2e, 0x69,
0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x73, 0x28, 0x60, 0x24,
0x7b, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x69, 0x6e,
0x4e, 0x75, 0x6d, 0x7d, 0x2f, 0x24, 0x7b, 0x66, 0x6e, 0x7d,
0x60, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x6d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x2d, 0x20, 0x64,
0x61, 0x74, 0x61, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20,
0x73, 0x65, 0x6e, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68,
0x65, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x20,
0x20, 0x2a, 0x20, 0x40, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x2d, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x20, 0x6f, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62,
0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x20, 0x63, 0x61, 0x6c,
0x6c, 0x62, 0x61, 0x63, 0x6b, 0x20, 0x73, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x0a, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x65, 0x78,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x20, 0x2d, 0x20, 0x63, 0x6f,
0x6e, 0x73, 0x74, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20,
0x61, 0x77, 0x61, 0x69, 0x74, 0x20, 0x77, 0x65, 0x62, 0x75,
0x69, 0x2e, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x22, 0x6d, 0x79,
0x49, 0x44, 0x22, 0x2c, 0x20, 0x31, 0x32, 0x33, 0x2c, 0x20,
0x74, 0x72, 0x75, 0x65, 0x2c, 0x20, 0x22, 0x48, 0x69, 0x22,
0x2c, 0x20, 0x6e, 0x65, 0x77, 0x20, 0x55, 0x69, 0x6e, 0x74,
0x38, 0x41, 0x72, 0x72, 0x61, 0x79, 0x28, 0x5b, 0x30, 0x78,
0x34, 0x32, 0x2c, 0x20, 0x30, 0x78, 0x34, 0x33, 0x2c, 0x20,
0x30, 0x78, 0x34, 0x34, 0x5d, 0x29, 0x29, 0x0a, 0x20, 0x20,
0x2a, 0x2f, 0x0a, 0x20, 0x20, 0x61, 0x73, 0x79, 0x6e, 0x63,
0x20, 0x63, 0x61, 0x6c, 0x6c, 0x28, 0x66, 0x6e, 0x2c, 0x20,
0x2e, 0x2e, 0x2e, 0x61, 0x72, 0x67, 0x73, 0x29, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21,
0x66, 0x6e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x50, 0x72, 0x6f,
0x6d, 0x69, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6a, 0x65, 0x63,
0x74, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x52, 0x65, 0x66, 0x65,
0x72, 0x65, 0x6e, 0x63, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72,
0x28, 0x60, 0x4e, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x64, 0x69,
0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, 0x66, 0x6f, 0x75,
0x6e, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x22, 0x24, 0x7b,
0x66, 0x6e, 0x7d, 0x22, 0x60, 0x29, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x68, 0x69,
0x73, 0x2e, 0x23, 0x6c, 0x6f, 0x67, 0x29, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c,
0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x60, 0x57, 0x65, 0x62,
0x55, 0x49, 0x20, 0x2d, 0x3e, 0x20, 0x43, 0x61, 0x6c, 0x6c,
0x69, 0x6e, 0x67, 0x20, 0x5b, 0x24, 0x7b, 0x66, 0x6e, 0x7d,
0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x5d, 0x60, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20,
0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x20, 0x3d,
0x20, 0x61, 0x77, 0x61, 0x69, 0x74, 0x20, 0x74, 0x68, 0x69,
0x73, 0x2e, 0x23, 0x63, 0x61, 0x6c, 0x6c, 0x50, 0x72, 0x6f,
0x6d, 0x69, 0x73, 0x65, 0x28, 0x66, 0x6e, 0x2c, 0x20, 0x2e,
0x2e, 0x2e, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79, 0x70,
0x65, 0x6f, 0x66, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x22, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x22, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x20,
0x20, 0x2f, 0x2a, 0x2a, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20,
0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x6f, 0x72, 0x20,
0x64, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65,
0x20, 0x77, 0x65, 0x62, 0x75, 0x69, 0x20, 0x64, 0x65, 0x62,
0x75, 0x67, 0x20, 0x6c, 0x6f, 0x67, 0x67, 0x69, 0x6e, 0x67,
0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20,
0x2a, 0x20, 0x40, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x20, 0x73,
0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x2d, 0x20, 0x6c, 0x6f,
0x67, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x74,
0x6f, 0x20, 0x73, 0x65, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x2a,
0x2f, 0x0a, 0x20, 0x20, 0x73, 0x65, 0x74, 0x4c, 0x6f, 0x67,
0x67, 0x69, 0x6e, 0x67, 0x28, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
0x66, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x29,
0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63,
0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67,
0x28, 0x22, 0x57, 0x65, 0x62, 0x55, 0x49, 0x20, 0x2d, 0x3e,
0x20, 0x4c, 0x6f, 0x67, 0x20, 0x45, 0x6e, 0x61, 0x62, 0x6c,
0x65, 0x64, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x6c,
0x6f, 0x67, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x74, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x53, 0x79, 0x6e, 0x74,
0x61, 0x78, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x22, 0x4e,
0x6f, 0x20, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x20,
0x6e, 0x61, 0x6d, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, 0x72,
0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x22, 0x29, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x21,
0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x73, 0x53, 0x74,
0x61, 0x74, 0x75, 0x73, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x50,
0x72, 0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6a,
0x65, 0x63, 0x74, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x45, 0x72,
0x72, 0x6f, 0x72, 0x28, 0x22, 0x57, 0x65, 0x62, 0x53, 0x6f,
0x63, 0x6b, 0x65, 0x74, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f,
0x74, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x65,
0x64, 0x22, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x69, 0x66, 0x20, 0x28, 0x21, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x68, 0x61, 0x73, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73,
0x20, 0x26, 0x26, 0x20, 0x21, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x62, 0x69, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x2e,
0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x73, 0x28, 0x60,
0x24, 0x7b, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23, 0x77, 0x69,
0x6e, 0x4e, 0x75, 0x6d, 0x7d, 0x2f, 0x24, 0x7b, 0x66, 0x6e,
0x7d, 0x60, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x50, 0x72,
0x6f, 0x6d, 0x69, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x6a, 0x65,
0x63, 0x74, 0x28, 0x6e, 0x65, 0x77, 0x20, 0x52, 0x65, 0x66,
0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x45, 0x72, 0x72, 0x6f,
0x72, 0x28, 0x60, 0x4e, 0x6f, 0x20, 0x62, 0x69, 0x6e, 0x64,
0x69, 0x6e, 0x67, 0x20, 0x77, 0x61, 0x73, 0x20, 0x66, 0x6f,
0x75, 0x6e, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x22, 0x24,
0x7b, 0x66, 0x6e, 0x7d, 0x22, 0x60, 0x29, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x68,
0x69, 0x73, 0x2e, 0x23, 0x6c, 0x6f, 0x67, 0x29, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f,
0x6c, 0x65, 0x2e, 0x6c, 0x6f, 0x67, 0x28, 0x60, 0x57, 0x65,
0x62, 0x55, 0x49, 0x20, 0x2d, 0x3e, 0x20, 0x43, 0x61, 0x6c,
0x6c, 0x69, 0x6e, 0x67, 0x20, 0x5b, 0x24, 0x7b, 0x66, 0x6e,
0x7d, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x5d, 0x60, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74,
0x20, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x20,
0x3d, 0x20, 0x61, 0x77, 0x61, 0x69, 0x74, 0x20, 0x74, 0x68,
0x69, 0x73, 0x2e, 0x23, 0x63, 0x61, 0x6c, 0x6c, 0x50, 0x72,
0x6f, 0x6d, 0x69, 0x73, 0x65, 0x28, 0x66, 0x6e, 0x2c, 0x20,
0x2e, 0x2e, 0x2e, 0x61, 0x72, 0x67, 0x73, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, 0x74, 0x79,
0x70, 0x65, 0x6f, 0x66, 0x20, 0x72, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x20, 0x21, 0x3d, 0x3d, 0x20, 0x22, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x29, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x22, 0x22, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a,
0x20, 0x20, 0x2f, 0x2a, 0x2a, 0x0a, 0x20, 0x20, 0x20, 0x2a,
0x20, 0x41, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20, 0x6f, 0x72,
0x20, 0x64, 0x65, 0x61, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74,
0x65, 0x20, 0x77, 0x65, 0x62, 0x75, 0x69, 0x20, 0x64, 0x65,
0x62, 0x75, 0x67, 0x20, 0x6c, 0x6f, 0x67, 0x67, 0x69, 0x6e,
0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x0a, 0x20, 0x20,
0x20, 0x2a, 0x20, 0x40, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x20,
0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x20, 0x2d, 0x20, 0x6c,
0x6f, 0x67, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x20,
0x74, 0x6f, 0x20, 0x73, 0x65, 0x74, 0x0a, 0x20, 0x20, 0x20,
0x2a, 0x2f, 0x0a, 0x20, 0x20, 0x73, 0x65, 0x74, 0x4c, 0x6f,
0x67, 0x67, 0x69, 0x6e, 0x67, 0x28, 0x73, 0x74, 0x61, 0x74,
0x75, 0x73, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x69, 0x66, 0x20, 0x28, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73,
0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c, 0x6f,
0x67, 0x28, 0x22, 0x57, 0x65, 0x62, 0x55, 0x49, 0x20, 0x2d,
0x3e, 0x20, 0x4c, 0x6f, 0x67, 0x20, 0x44, 0x69, 0x73, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e,
0x23, 0x6c, 0x6f, 0x67, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c,
0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a,
0x3e, 0x20, 0x4c, 0x6f, 0x67, 0x20, 0x45, 0x6e, 0x61, 0x62,
0x6c, 0x65, 0x64, 0x2e, 0x22, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x23,
0x6c, 0x6f, 0x67, 0x20, 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c,
0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x2e, 0x6c,
0x6f, 0x67, 0x28, 0x22, 0x57, 0x65, 0x62, 0x55, 0x49, 0x20,
0x2d, 0x3e, 0x20, 0x4c, 0x6f, 0x67, 0x20, 0x44, 0x69, 0x73,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x2e, 0x22, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x74, 0x68, 0x69, 0x73,
0x2e, 0x23, 0x6c, 0x6f, 0x67, 0x20, 0x3d, 0x20, 0x66, 0x61,
0x6c, 0x73, 0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d,
0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x2f, 0x2a, 0x2a,
0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x45, 0x6e, 0x63, 0x6f,
0x64, 0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x69, 0x6e,
0x74, 0x6f, 0x20, 0x62, 0x61, 0x73, 0x65, 0x36, 0x34, 0x20,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20,
0x2a, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x70,
0x61, 0x72, 0x61, 0x6d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20,
0x2d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x73, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x2f, 0x0a,
0x20, 0x20, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x28, 0x64,
0x61, 0x74, 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x74,
0x6f, 0x61, 0x28, 0x64, 0x61, 0x74, 0x61, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x2f, 0x2a, 0x2a, 0x0a,
0x20, 0x20, 0x20, 0x2a, 0x20, 0x45, 0x6e, 0x63, 0x6f, 0x64,
0x65, 0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x69, 0x6e, 0x74,
0x6f, 0x20, 0x62, 0x61, 0x73, 0x65, 0x36, 0x34, 0x20, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a,
0x20, 0x20, 0x20, 0x2a, 0x20, 0x44, 0x65, 0x63, 0x6f, 0x64,
0x65, 0x20, 0x62, 0x61, 0x73, 0x65, 0x36, 0x34, 0x20, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x74, 0x6f,
0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x2a,
0x20, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x2d,
0x20, 0x74, 0x65, 0x78, 0x74, 0x20, 0x73, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x2f, 0x0a, 0x20,
0x20, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x28, 0x64, 0x61,
0x74, 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x74, 0x6f,
0x61, 0x28, 0x64, 0x61, 0x74, 0x61, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x7d, 0x0a, 0x20, 0x20, 0x2f, 0x2a, 0x2a, 0x0a, 0x20,
0x20, 0x20, 0x2a, 0x20, 0x44, 0x65, 0x63, 0x6f, 0x64, 0x65,
0x20, 0x62, 0x61, 0x73, 0x65, 0x36, 0x34, 0x20, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x6e, 0x74, 0x6f, 0x20,
0x74, 0x65, 0x78, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20,
0x0a, 0x20, 0x20, 0x20, 0x2a, 0x20, 0x40, 0x70, 0x61, 0x72,
0x61, 0x6d, 0x20, 0x64, 0x61, 0x74, 0x61, 0x20, 0x2d, 0x20,
0x62, 0x61, 0x73, 0x65, 0x36, 0x34, 0x20, 0x73, 0x74, 0x72,
0x69, 0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x2f, 0x0a,
0x20, 0x20, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x28, 0x64,
0x61, 0x74, 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x74,
0x6f, 0x62, 0x28, 0x64, 0x61, 0x74, 0x61, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x3b, 0x0a, 0x61, 0x64, 0x64,
0x72, 0x69, 0x6e, 0x67, 0x0a, 0x20, 0x20, 0x20, 0x2a, 0x2f,
0x0a, 0x20, 0x20, 0x64, 0x65, 0x63, 0x6f, 0x64, 0x65, 0x28,
0x64, 0x61, 0x74, 0x61, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61,
0x74, 0x6f, 0x62, 0x28, 0x64, 0x61, 0x74, 0x61, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x3b, 0x0a, 0x61, 0x64,
0x64, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74,
0x65, 0x6e, 0x65, 0x72, 0x28, 0x22, 0x6c, 0x6f, 0x61, 0x64,
0x22, 0x2c, 0x20, 0x28, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b,
0x0a, 0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e,
0x74, 0x2e, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x61, 0x64, 0x64,
0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65,
0x6e, 0x65, 0x72, 0x28, 0x22, 0x6c, 0x6f, 0x61, 0x64, 0x22,
0x2c, 0x20, 0x28, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x7b, 0x0a,
0x6e, 0x65, 0x72, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22,
0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6d, 0x65, 0x6e,
0x75, 0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x65,
0x76, 0x65, 0x6e, 0x74, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x65,
0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x65, 0x76, 0x65,
0x6e, 0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x28,
0x29, 0x0a, 0x20, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x61,
0x64, 0x64, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x61,
0x62, 0x6c, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69,
0x73, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74,
0x2e, 0x62, 0x6f, 0x64, 0x79, 0x2e, 0x61, 0x64, 0x64, 0x45,
0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e,
0x65, 0x72, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x22, 0x63,
0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x6d, 0x65, 0x6e, 0x75,
0x22, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x28, 0x65, 0x76,
0x65, 0x6e, 0x74, 0x29, 0x20, 0x3d, 0x3e, 0x20, 0x65, 0x76,
0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x65, 0x76, 0x65, 0x6e,
0x74, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x28, 0x29,
0x0a, 0x20, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x61, 0x64,
0x64, 0x52, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x61, 0x62,
0x6c, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73,
0x74, 0x65, 0x6e, 0x65, 0x72, 0x28, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e,
0x62, 0x6f, 0x64, 0x79, 0x2c, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x22, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78,
0x74, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x2c, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29, 0x20,
0x3d, 0x3e, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x73,
0x74, 0x6f, 0x70, 0x50, 0x72, 0x6f, 0x70, 0x61, 0x67, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x29,
0x3b, 0x0a, 0x7d, 0x29, 0x3b, 0x0a,
0x2e, 0x62, 0x6f, 0x64, 0x79, 0x2c, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x22, 0x69, 0x6e, 0x70, 0x75, 0x74, 0x22, 0x2c, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65,
0x78, 0x74, 0x6d, 0x65, 0x6e, 0x75, 0x22, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x28, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x29,
0x20, 0x3d, 0x3e, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e,
0x73, 0x74, 0x6f, 0x70, 0x50, 0x72, 0x6f, 0x70, 0x61, 0x67,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x0a, 0x20, 0x20,
0x29, 0x3b, 0x0a, 0x7d, 0x29, 0x3b, 0x0a,
0x00
};

View File

@ -574,7 +574,7 @@ class WebuiBridge {
// 1: [TOKEN]
// 2: [ID]
// 3: [CMD]
// 4: [Fn, Null, {Len;Len;...}, Null, {Data,Null,Data,Null...}, Null]
// 4: [Fn, Null, {Len;Len;...}, Null, {Data,Null,Data,Null...}]
const packet = Uint8Array.of(
this.#WEBUI_SIGNATURE,
0, 0, 0, 0, // Token (4 Bytes)
@ -584,8 +584,7 @@ class WebuiBridge {
0,
...new TextEncoder().encode(argsLengths),
0,
...argsValues,
0
...argsValues
)
this.#addToken(packet, this.#token, this.#PROTOCOL_TOKEN)
this.#addID(packet, callId, this.#PROTOCOL_ID)

View File

@ -57,11 +57,14 @@ void my_function_raw_binary(webui_event_t* e) {
printf("0x%02x ", raw_1[i]);
printf("\n");
// Check raw_2 (Big)
// [0xA1, 0x00..., 0xA2]
bool valid = false;
if(raw_2[0] == 0xA1 && raw_2[len_2 - 1] == 0xA2)
valid = true;
// Print raw_2
printf("my_function_raw_binary 2 (%llu bytes): ", len_2);
for (size_t i = 0; i < len_2; i++)
printf("0x%02x ", raw_2[i]);
printf("\n");
printf("my_function_raw_binary 2 big (%llu bytes): valid data? %s\n", len_2, (valid ? "Yes" : "No"));
}
void my_function_with_response(webui_event_t* e) {
@ -90,15 +93,29 @@ int main() {
" <title>Call C from JavaScript Example</title>"
" <style>"
" body {"
" background: linear-gradient(to left, #36265a, #654da9);"
" color: AliceBlue;"
" font: 16px sans-serif;"
" font-family: 'Arial', sans-serif;"
" color: white;"
" background: linear-gradient(to right, #507d91, #1c596f, #022737);"
" text-align: center;"
" margin-top: 30px;"
" font-size: 18px;"
" }"
" button, input {"
" padding: 10px;"
" margin: 10px;"
" border-radius: 3px;"
" border: 1px solid #ccc;"
" box-shadow: 0 3px 5px rgba(0,0,0,0.1);"
" transition: 0.2s;"
" }"
" button {"
" margin: 5px 0 10px;"
" background: #3498db;"
" color: #fff; "
" cursor: pointer;"
" font-size: 16px;"
" }"
" h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }"
" button:hover { background: #c9913d; }"
" input:focus { outline: none; border-color: #3498db; }"
" </style>"
" </head>"
" <body>"
@ -110,12 +127,16 @@ int main() {
" <br>"
" <button onclick=\"webui.call('MyID_Three', true, false);\">Call my_function_boolean()</button>"
" <br>"
" <button onclick=\"webui.call('MyID_RawBinary', new Uint8Array([0x41]), new Uint8Array([0x42, 0x43]));\">Call my_function_raw_binary()</button>"
" <button onclick=\"webui.call('MyID_RawBinary', new Uint8Array([0x41,0x42,0x43]), big_arr);\">Call my_function_raw_binary()</button>"
" <br>"
" <p>Call a C function that returns a response</p>"
" <button onclick=\"MyJS();\">Call my_function_with_response()</button>"
" <div>Double: <input type=\"text\" id=\"MyInputID\" value=\"2\"></div>"
" <script>"
" const arr_size = 10000;"
" const big_arr = new Uint8Array(arr_size);"
" big_arr[0] = 0xA1;"
" big_arr[arr_size - 1] = 0xA2;"
" function MyJS() {"
" const MyInput = document.getElementById('MyInputID');"
" const number = MyInput.value;"

View File

@ -50,15 +50,29 @@ int main() {
" <title>Call JavaScript from C Example</title>"
" <style>"
" body {"
" background: linear-gradient(to left, #36265a, #654da9);"
" color: AliceBlue;"
" font: 16px sans-serif;"
" font-family: 'Arial', sans-serif;"
" color: white;"
" background: linear-gradient(to right, #507d91, #1c596f, #022737);"
" text-align: center;"
" margin-top: 30px;"
" font-size: 18px;"
" }"
" button, input {"
" padding: 10px;"
" margin: 10px;"
" border-radius: 3px;"
" border: 1px solid #ccc;"
" box-shadow: 0 3px 5px rgba(0,0,0,0.1);"
" transition: 0.2s;"
" }"
" button {"
" margin: 5px 0 10px;"
" background: #3498db;"
" color: #fff; "
" cursor: pointer;"
" font-size: 16px;"
" }"
" h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }"
" button:hover { background: #c9913d; }"
" input:focus { outline: none; border-color: #3498db; }"
" </style>"
" </head>"
" <body>"

View File

@ -5,14 +5,29 @@
<title>WebUI - Serve a Folder Example (C99)</title>
<style>
body {
font-family: 'Arial', sans-serif;
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #3e6983, #314562, #10273e);
background: linear-gradient(to right, #3e6983, #314562, #10273e);
background: linear-gradient(to right, #507d91, #1c596f, #022737);
text-align: center;
font-size: 16px;
font-family: sans-serif;
font-size: 18px;
}
button, input {
padding: 10px;
border-radius: 3px;
border: 1px solid #ccc;
box-shadow: 0 3px 5px rgba(0,0,0,0.1);
transition: 0.2s;
}
button {
background: #3498db;
color: #fff;
cursor: pointer;
font-size: 16px;
}
h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }
button:hover { background: #c9913d; }
input:focus { outline: none; border-color: #3498db; }
a:link{color:#fd5723}
a:active{color:#fd5723}
a:visited{color:#fd5723}

View File

@ -5,14 +5,28 @@
<title>WebUI - Second Page (C99)</title>
<style>
body {
font-family: 'Arial', sans-serif;
color: white;
background: #0F2027;
background: -webkit-linear-gradient(to right, #3e6983, #314562, #10273e);
background: linear-gradient(to right, #3e6983, #314562, #10273e);
background: linear-gradient(to right, #507d91, #1c596f, #022737);
text-align: center;
font-size: 16px;
font-family: sans-serif;
font-size: 18px;
}
button, input {
padding: 10px;
border-radius: 3px;
border: 1px solid #ccc;
box-shadow: 0 3px 5px rgba(0,0,0,0.1);
transition: 0.2s;
}
button {
background: #3498db;
color: #fff;
cursor: pointer;
font-size: 16px;
}
h1 { text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); }
button:hover { background: #c9913d; }
input:focus { outline: none; border-color: #3498db; }
</style>
</head>
<body>

View File

@ -5205,6 +5205,9 @@ static size_t _webui_set_cb_index(char* webui_internal_id) {
}
static void _webui_print_ascii(const char* data, size_t len) {
for (size_t i = 0; i < len; i++) {
if((unsigned char)*data == 0x00)
putchar(0xCF); // ¤
else
printf("%c", (unsigned char)*data);
data++;
}
@ -5994,7 +5997,7 @@ static WEBUI_THREAD_SERVER_START
static void _webui_receive(_webui_window_t* win, int event_type, void* data, size_t len) {
#ifdef WEBUI_LOG
printf("[Core]\t\t_webui_receive()...\n");
printf("[Core]\t\t_webui_receive([%zu], [%d], [%zu])...\n", win->window_number, event_type, len);
#endif
static size_t recvNum = 0;
@ -6045,7 +6048,7 @@ static WEBUI_THREAD_RECEIVE
// Get arguments
_webui_recv_arg_t* arg = (_webui_recv_arg_t*) _arg;
_webui_window_t* win = arg->win;
size_t len = arg->len;
size_t packet_len = arg->len;
size_t recvNum = arg->recvNum;
size_t event_type = arg->event_type;
void* ptr = arg->ptr;
@ -6064,18 +6067,18 @@ static WEBUI_THREAD_RECEIVE
#ifdef WEBUI_LOG
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Data received...\n", recvNum);
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet Size : %zu bytes\n", recvNum, len);
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet Size : %zu bytes\n", recvNum, packet_len);
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet Header : [ ", recvNum);
_webui_print_hex(packet, WEBUI_PROTOCOL_SIZE);
printf("]\n");
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet Token: 0x%08X (%" PRIu32 ")\n", recvNum, packet_token, packet_token);
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet ID: 0x%04X (%u)\n", recvNum, packet_id, packet_id);
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Packet Data: [", recvNum);
_webui_print_ascii(&packet[WEBUI_PROTOCOL_DATA], (len - WEBUI_PROTOCOL_SIZE));
_webui_print_ascii(&packet[WEBUI_PROTOCOL_DATA], (packet_len - WEBUI_PROTOCOL_SIZE));
printf("]\n");
#endif
if(len >= WEBUI_PROTOCOL_SIZE && (unsigned char)packet[WEBUI_PROTOCOL_SIGN] == WEBUI_SIGNATURE && packet_token == win->token) {
if(packet_len >= WEBUI_PROTOCOL_SIZE && (unsigned char)packet[WEBUI_PROTOCOL_SIGN] == WEBUI_SIGNATURE && packet_token == win->token) {
// Mutex
// wait for previous event to finish
@ -6232,7 +6235,7 @@ static WEBUI_THREAD_RECEIVE
// Function Call
// 0: [Header]
// 1: [Fn, Null, {Len;Len;...}, Null, {Data,Null,Data,Null...}, Null]
// 1: [Fn, Null, {Len;Len;...}, Null, {Data,Null,Data,Null...}]
// Get html element id
char* element = (char*)&packet[WEBUI_PROTOCOL_DATA];
@ -6255,13 +6258,16 @@ static WEBUI_THREAD_RECEIVE
win->events[event_num] = event_inf;
// Loop trough args
size_t data_size_expected = 0;
char* args_lens = (char*)&packet[WEBUI_PROTOCOL_DATA + element_len + 1];
char* args_ptr = (char*)&packet[WEBUI_PROTOCOL_DATA + element_len + 1 + _webui_strlen(args_lens) + 1];
size_t args_len = _webui_strlen(args_lens);
char* args_ptr = (char*)&packet[WEBUI_PROTOCOL_DATA + element_len + 1 + args_len + 1];
char* token = strtok(args_lens, ";");
size_t token_num = 0;
while (token != NULL) {
size_t arg_len = (size_t)strtoul(token, NULL, 10);
data_size_expected = data_size_expected + arg_len + 1;
if(arg_len > 0) {
@ -6279,6 +6285,20 @@ static WEBUI_THREAD_RECEIVE
token = strtok(NULL, ";");
}
// Check data validity
size_t data_size_recv = packet_len - (
WEBUI_PROTOCOL_SIZE + // [Header]
element_len + // [Fn]
1 + // [Null]
args_len + // [{Len;Len;...}]
1); // [Null]
if(data_size_expected == data_size_recv) {
#ifdef WEBUI_LOG
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> Expected and received %zu bytes of data.\n", recvNum, data_size_expected);
#endif
// Create new event
webui_event_t e;
e.window = win->window_number;
@ -6315,8 +6335,28 @@ static WEBUI_THREAD_RECEIVE
_webui_send(win, win->token, packet_id, WEBUI_CMD_CALL_FUNC, event_inf->response, _webui_strlen(event_inf->response));
// Free event
_webui_free_mem((void*)webui_internal_id);
_webui_free_mem((void*)event_inf->response);
}
else {
// WebSocket/Civetweb did not send all the data as expected.
#ifdef WEBUI_LOG
printf("[Core]\t\t[Thread %zu] _webui_receive_thread() -> No enough data received. Expected %zu bytes, received %zu bytes.\n", recvNum, data_size_expected, data_size_recv);
#endif
// Send a void response to solve `.call()` promise
// Packet Protocol Format:
// [...]
// [CMD]
// [CallResponse]
// Send the packet
_webui_send(win, win->token, packet_id, WEBUI_CMD_CALL_FUNC, NULL, 0);
}
// Free event
_webui_free_mem((void*)webui_internal_id);
_webui_free_mem((void*)event_inf);
}
#ifdef WEBUI_LOG