Add AI prompt support in the source

parent ac3b4252
- 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
- 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 websocket.c is user ALSO for the websockets in the communication port with wssshc and wsssht, if you modify something for vnc or rdp or anything in the web interface, don't break the implementation for the wssshc-wssshd-wsssht communication channel/protocol
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "html_pages/mstsc_page.h" #include "html_pages/mstsc_page.h"
#include "html_pages/novnc_css_page.h" #include "html_pages/novnc_css_page.h"
#include "novnc_asset_map.c" #include "novnc_asset_map.c"
#include "rdp_assets.h"
#include "rdp_asset_map.c"
// HTML pages are now defined in separate header files in html_pages/ directory // HTML pages are now defined in separate header files in html_pages/ directory
// This file now only contains fallback definitions for compatibility // This file now only contains fallback definitions for compatibility
...@@ -76,6 +78,9 @@ const char *get_embedded_asset(const char *path, size_t *size) { ...@@ -76,6 +78,9 @@ const char *get_embedded_asset(const char *path, size_t *size) {
const char *content = get_novnc_asset(path); const char *content = get_novnc_asset(path);
if (content && size) *size = strlen(content); if (content && size) *size = strlen(content);
return content; return content;
} else if (strncmp(path, "/rdp/", 5) == 0) {
const char *content = get_rdp_asset(path, size);
return content;
} }
return NULL; return NULL;
......
...@@ -225,6 +225,75 @@ static const char *mstsc_js = ""; ...@@ -225,6 +225,75 @@ static const char *mstsc_js = "";
EOF EOF
fi fi
# Embed RDP JS files
echo "Embedding RDP JS files..."
mkdir -p html_pages
# Generate rdp_assets.h
cat > rdp_assets.h << 'EOF'
#ifndef RDP_ASSETS_H
#define RDP_ASSETS_H
EOF
# Generate rdp_asset_map.c
cat > rdp_asset_map.c << 'EOF'
#include <string.h>
#include "rdp_assets.h"
const char *get_rdp_asset(const char *path, size_t *size) {
EOF
find templates/rdp -name "*.wasm" | sort | while read -r file; do
if [ -f "$file" ]; then
RELPATH=$(echo "$file" | sed 's|templates/rdp/||')
VARNAME=$(echo "$RELPATH" | sed 's|/|_|g; s|\.wasm$|_wasm|; 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 unsigned char rdp_${VARNAME}[];
extern const unsigned int rdp_${VARNAME}_len;
#endif /* RDP_${VARNAME^^}_PAGE_H */
EOF
# Add to rdp_assets.h
echo "#include \"html_pages/rdp_${VARNAME}_page.h\"" >> rdp_assets.h
# 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/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 (size) *size = rdp_${VARNAME}_len;" >> rdp_asset_map.c
echo " return (const char *)rdp_${VARNAME};" >> rdp_asset_map.c
echo " }" >> rdp_asset_map.c
fi
done
cat >> rdp_assets.h << 'EOF'
#endif /* RDP_ASSETS_H */
EOF
cat >> rdp_asset_map.c << 'EOF'
return NULL;
}
EOF
echo "RDP JS files embedded."
# Embed noVNC CSS # Embed noVNC CSS
if [ -f templates/novnc.css ]; then if [ -f templates/novnc.css ]; then
echo "Embedding novnc.css..." echo "Embedding novnc.css..."
......
This diff is collapsed.
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#include "html_pages/novnc_input_fixedkeys_js_page.h" #include "html_pages/novnc_input_fixedkeys_js_page.h"
#include "html_pages/novnc_input_gesturehandler_js_page.h" #include "html_pages/novnc_input_gesturehandler_js_page.h"
#include "html_pages/novnc_input_keyboard_js_page.h" #include "html_pages/novnc_input_keyboard_js_page.h"
#include "html_pages/novnc_input_keysymdef_js_page.h"
#include "html_pages/novnc_input_keysym_js_page.h" #include "html_pages/novnc_input_keysym_js_page.h"
#include "html_pages/novnc_input_keysymdef_js_page.h"
#include "html_pages/novnc_input_util_js_page.h" #include "html_pages/novnc_input_util_js_page.h"
#include "html_pages/novnc_input_vkeys_js_page.h" #include "html_pages/novnc_input_vkeys_js_page.h"
#include "html_pages/novnc_input_xtscancodes_js_page.h" #include "html_pages/novnc_input_xtscancodes_js_page.h"
......
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