Rename RDP template directory to rdpwasm to separate JS assets from RDP page path

- Renamed templates/rdp/ to templates/rdpwasm/
- Updated embed_assets.sh to embed from rdpwasm and map to /rdpwasm/ paths
- Updated rdp.html to load scripts from /rdpwasm/
- Regenerated Makefile and rebuilt successfully
parent 06a17b30
......@@ -2,4 +2,6 @@
- if you need to build the debian packages, use ./build.sh --debian
- if a build give you any warning, fix the warning
- when you finish a todo list and everything is complete, execute a git commit
- If you need to rebuild the project, use always ./build.sh --clean && ./build.sh
- if you need to build the debian packages, use ./build.sh --debian
- when you finish a todo list and everything is complete, execute a git commit
temp_rdp_wasm @ 4477a0bc
Subproject commit 4477a0bcc46bc390780e73664bf678fbaaece2ac
- the html pages and the assets to add in wssshd are generated from the templates directory, using the script embed_assets.sh.
- the script embed_assets.sh is launched by the Makefile
- the Makefile is generated by the script configure.sh
- in wssshd webinterface, the vnc page and the rdp page uses different websocket implementation, looks at the specifics of web.c and vnc.c or rdp.c, the file
......@@ -244,9 +244,52 @@ const char *get_rdp_asset(const char *path, size_t *size) {
EOF
find templates/rdp -name "*.wasm" | sort | while read -r file; do
find templates/rdpwasm -name "*.js" | sort | while read -r file; do
if [ -f "$file" ]; then
RELPATH=$(echo "$file" | sed 's|templates/rdp/||')
RELPATH=$(echo "$file" | sed 's|templates/rdpwasm/||')
VARNAME=$(echo "$RELPATH" | sed 's|/|_|g; s|\.js$|_js|; s|\.|_|g')
HEADER_FILE="html_pages/rdp_${VARNAME}_page.h"
echo "Embedding $file as rdp_${VARNAME}"
# Create header with extern
cat > "$HEADER_FILE" << EOF
#ifndef RDP_${VARNAME^^}_PAGE_H
#define RDP_${VARNAME^^}_PAGE_H
extern const char *rdp_${VARNAME};
#endif /* RDP_${VARNAME^^}_PAGE_H */
EOF
# Add to rdp_assets.h
echo "#include \"html_pages/rdp_${VARNAME}_page.h\"" >> rdp_assets.h
# Add definition to rdp_asset_map.c
echo "const char *rdp_${VARNAME} =" >> rdp_asset_map.c
# Use python to properly escape
python3 -c "
import sys
with open('$file', 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
lines = content.split('\n')
for line in lines:
escaped_line = line.replace('\\\\', '\\\\\\\\').replace('\\\"', '\\\\\"')
print('\"' + escaped_line + '\\\\n\"')
" >> rdp_asset_map.c
echo ";" >> rdp_asset_map.c
# Add to rdp_asset_map.c
echo " if (strcmp(path, \"/rdpwasm/$RELPATH\") == 0) {" >> rdp_asset_map.c
echo " if (size) *size = strlen(rdp_${VARNAME});" >> rdp_asset_map.c
echo " return rdp_${VARNAME};" >> rdp_asset_map.c
echo " }" >> rdp_asset_map.c
fi
done
find templates/rdpwasm -name "*.wasm" | sort | while read -r file; do
if [ -f "$file" ]; then
RELPATH=$(echo "$file" | sed 's|templates/rdpwasm/||')
VARNAME=$(echo "$RELPATH" | sed 's|/|_|g; s|\.wasm$|_wasm|; s|\.|_|g')
HEADER_FILE="html_pages/rdp_${VARNAME}_page.h"
......@@ -269,14 +312,14 @@ EOF
# Embed binary file
xxd -i "$file" > temp_binary.h
# Rename the variables and add static
sed -i "s/templates_rdp_rdp_wasm/rdp_rdp_wasm/g" temp_binary.h
sed -i "s/templates_rdpwasm_rdp_wasm/rdp_rdp_wasm/g" temp_binary.h
sed -i "s/unsigned char rdp_rdp_wasm\[\]/static unsigned char rdp_rdp_wasm[]/g" temp_binary.h
sed -i "s/unsigned int rdp_rdp_wasm_len/static unsigned int rdp_rdp_wasm_len/g" temp_binary.h
cat temp_binary.h >> rdp_asset_map.c
rm temp_binary.h
# Add to rdp_asset_map.c
echo " if (strcmp(path, \"/rdp/$RELPATH\") == 0) {" >> rdp_asset_map.c
echo " if (strcmp(path, \"/rdpwasm/$RELPATH\") == 0) {" >> rdp_asset_map.c
echo " if (size) *size = rdp_${VARNAME}_len;" >> rdp_asset_map.c
echo " return (const char *)rdp_${VARNAME};" >> rdp_asset_map.c
echo " }" >> rdp_asset_map.c
......
This diff is collapsed.
#ifndef RDP_ASSETS_H
#define RDP_ASSETS_H
#include "html_pages/rdp_clipboard_js_page.h"
#include "html_pages/rdp_mstsc_js_page.h"
#include "html_pages/rdp_out_stream_js_page.h"
#include "html_pages/rdp_rdp_wasm_js_page.h"
#include "html_pages/rdp_rdp_graphics_js_page.h"
#include "html_pages/rdp_reversed_layouts_js_page.h"
#include "html_pages/rdp_scancodes_js_page.h"
#include "html_pages/rdp_rdp_wasm_page.h"
#endif /* RDP_ASSETS_H */
......@@ -7,12 +7,12 @@
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<script src="/rdp/rdp.wasm.js"></script>
<script src="/rdp/clipboard.js"></script>
<script src="/rdp/out_stream.js"></script>
<script src="/rdp/rdp_graphics.js"></script>
<script src="/rdp/reversed_layouts.js"></script>
<script src="/rdp/scancodes.js"></script>
<script src="/rdpwasm/rdp.wasm.js"></script>
<script src="/rdpwasm/clipboard.js"></script>
<script src="/rdpwasm/out_stream.js"></script>
<script src="/rdpwasm/rdp_graphics.js"></script>
<script src="/rdpwasm/reversed_layouts.js"></script>
<script src="/rdpwasm/scancodes.js"></script>
<style>
.navbar-brand {
font-weight: bold;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"use strict";
class OutStream
{
constructor(ptr, emccModule) {
this.i = ptr;
this.HEAPU8 = emccModule.HEAPU8;
this.emccModule = emccModule;
}
skip(n) {
this.i += n;
}
u64lem(x) {
if (x > 0xffffffff) {
this.u32le(x - 0xffffffff);
}
else {
this.bzero(4);
}
this.u32le(x);
}
u64le(x) {
this.u32le(x);
if (x > 0xffffffff) {
this.u32le(x - 0xffffffff);
}
else {
this.bzero(4);
}
}
u32le(x) {
this.HEAPU8[this.i++] = x;
this.HEAPU8[this.i++] = (x >> 8);
this.HEAPU8[this.i++] = (x >> 16);
this.HEAPU8[this.i++] = (x >> 24);
}
u16le(x) {
this.HEAPU8[this.i++] = x;
this.HEAPU8[this.i++] = (x >> 8);
}
bzero(n) {
this.HEAPU8.fill(0, this.i, this.i + n);
this.i += n;
}
copyAsArray(array) {
this.HEAPU8.set(array, this.i);
this.i += array.length;
}
copyStringAsAlignedUTF16(str, maxBytesToWrite) {
if (maxBytesToWrite === undefined) {
maxBytesToWrite = 0x7FFFFFFF;
}
let iheap = this.i / 2;
const iend = (maxBytesToWrite < str.length * 2) ? (maxBytesToWrite >> 2) : str.length;
const HEAPU16 = this.emccModule.HEAPU16;
for (let i = 0; i < iend; ++i, ++iheap) {
HEAPU16[iheap] = str.charCodeAt(i);
}
this.i = iheap * 2;
return iend * 2;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment