diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..a46ed71 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +FROM docker.io/cyd01/cross-gcc:latest + +USER root + +ARG HOST_USER +ARG HOST_HOME +ARG HOST_SHELL + +RUN usermod --login ${HOST_USER} --home ${HOST_HOME} --move-home --shell ${HOST_SHELL} ${DEFAULT_USER} \ + && groupmod --new-name ${HOST_USER} ${DEFAULT_USER} \ + && usermod --groups root ${HOST_USER} \ + && echo "${HOST_USER} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/10-user + +ENV DEFAULT_USER=${HOST_USER} + +USER ${DEFAULT_USER} + +COPY ./scripts/ /usr/local/scripts/ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..e08f618 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,96 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.4/containers/ubuntu +{ + // nicely name your dev container environment (shown at left-hand bottom corner in VSCODE) + "name": "${containerWorkspaceFolderBasename}", + + // directly use our image + // "image": "docker.io/cyd01/cross-gcc:latest", + + // you can instead build an image using the included Dockerfile to do some tuning required at development only + // if required, tune Dockerfile, comment image and uncomment the following to trigger build at dev container creation + "build": { + "dockerfile": "Dockerfile", + "args": { + "HOST_USER": "${localEnv:USER}", + "HOST_HOME": "${localEnv:HOME}", + "HOST_SHELL": "${localEnv:SHELL}", + "BASE_IMAGE_NAME": "docker.io/cyd01/cross-gcc", + "BASE_IMAGE_TAG": "latest" + } + }, + + // mount your workspace: we mount in the exact same folder as the host one + "workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind,consistency=cached", + // you can choose to mount your workspace parent directory instead + //"workspaceMount": "source=${localWorkspaceFolder}/..,target=${localWorkspaceFolder}/..,type=bind,consistency=cached", + + // directory to use as workspace inside container: you can tune it if required + "workspaceFolder": "${localWorkspaceFolder}", + + "mounts": [ + "source=${localEnv:HOME},target=${localEnv:HOME}/host,type=bind,consistency=cached" + ], + + // VSCOde settings and extensions + "settings": { + "editor.insertSpaces": true, + "editor.tabSize": 4, + "terminal.explorerKind": "integrated", + "terminal.integrated.allowChords": false, + "terminal.integrated.drawBoldTextInBrightColors": false, + "terminal.integrated.experimentalLinkProvider": false, + "terminal.integrated.rendererType": "auto" + }, + "extensions": [ + "bierner.markdown-mermaid", + "dbaeumer.vscode-eslint", + "golang.go", + "sonatypecommunity.vscode-iq-plugin" + ], + // run custom + "postAttachCommand": "/usr/local/scripts/postAttach.sh", + // run in network host mode to acces published ports in local demo environments + "runArgs": [ + "--network", "host" + ], + + "remoteEnv": { + // forward some locally defined environment variables to container + "HISTFILE": "${localEnv:HISTFILE}", + "HISTSIZE": "${localEnv:HISTSIZE}", + // helpful variable so you go back to your local workspace folder + "WORKSPACE": "${localWorkspaceFolder}", + // + // set to 1 to debug postAttach.sh + "SCRIPTS_DEBUG": "1", + // + // default value for CGO_ENABLED is 0 in baseimage + // so it you really want to overwrite it, do it here + // "CGO_ENABLED": "1", + // + // HOST_FILES is used by postAttach to create symlinks to your host home files + // default means HISTFILE (e.g. bash_history) and .netrc + // you may say "default anotherfile" to also symlink that other file + "HOST_FILES": "default" + }, + + // user to start container with : make it root to allow VSCode to install/configure things. + // DO NOT CHANGE + "containerUser": "root", + // user to exec inside the container + // ubuntu if using base image + //"remoteUser": "ubuntu", + // your local user name if using a custom built image with your user in it + "remoteUser": "${localEnv:USER}", + + // update remote user uid : true by default + // added here to remind you remoteUser ids must be adjusted + "updateRemoteUserUID": true, + + "features": { + // this one is required for docker operations + // it will also add docker VSCODE extension + "docker-from-docker": "latest" + } +} \ No newline at end of file diff --git a/.devcontainer/scripts/postAttach.sh b/.devcontainer/scripts/postAttach.sh new file mode 100644 index 0000000..a502c27 --- /dev/null +++ b/.devcontainer/scripts/postAttach.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +DEBUG= +[ -n "${SCRIPTS_DEBUG}" ] && [ "${SCRIPTS_DEBUG}" != "0" ] && DEBUG=1 +[ -z "$DEBUG" ] && printf -- "\n" || printf -- "\e[39m| DEBUG | executing $0\e[39m\n" + + +test -r ~/host/.devcontainer_rc \ +&& { + [ -z "$DEBUG" ] || printf -- "\e[39m| DEBUG | checking for ~/host/.devcontainer_rc...\e[39m\n" + . ~/host/.devcontainer_rc \ + && printf -- "\e[92m| INFO | ~/host/.devcontainer_rc sucessfully executed\e[39m\n" \ + || printf -- "\e[91m| ERROR | ~/host/.devcontainer_rc \e[39m\n" +} \ +|| { + printf -- "\e[93m| WARN | no .devcontainer_rc file found in your home: create one to tune your configuration\e[39m\n"; +} + +HOST_FILES=${HOST_FILES:-default} +[ -z "$DEBUG" ] || printf -- "\e[39m| DEBUG | checking for HOST_FILES (${HOST_FILES})...\e[39m\n" +HOST_FILES_FINAL= +for f in ${HOST_FILES}; do + [ "${f}" = "default" ] \ + && { + [ -z "${HISTFILE}" ] \ + && printf -- "\e[93m| WARN | HISTFILE not defined : not exported on your host ?\e[39m\n" \ + || HOST_FILES_FINAL="${HOST_FILES_FINAL} ${HISTFILE#${HOME}/}" + HOST_FILES_FINAL="${HOST_FILES_FINAL} .netrc .makerc" + } \ + || HOST_FILES_FINAL="${HOST_FILES_FINAL} ${f}" +done +for f in ${HOST_FILES_FINAL}; do + hostf="${HOME}/host/${f#${HOME}/}" + [ -e ${hostf} ] \ + && { + cd ~ && ln -s -f ${hostf} ${f} \ + && printf -- "\e[92m| INFO | link for ${f} sucessfully created\e[39m\n" \ + || printf -- "\e[91m| ERROR | failed to create link for ${f}\e[39m\n" + } \ + || { + printf -- "\e[93m| WARN | ${f} link not created: host file (${hostf}) not found\e[39m\n" + } +done + +printf -- "\e[92m| INFO | $0 executed\e[39m\n" + +test -d $HOME/host && { + test -d /builds && sudo rm -rf /builds + mkdir -p $HOME/host/builds && sudo ln -sf $HOME/host/builds /builds + test -d /sources && sudo rm -rf /sources + mkdir -p $HOME/host/sources && sudo ln -sf $HOME/host/sources /sources +} \ No newline at end of file diff --git a/0.76_My_PuTTY/version.h b/0.76_My_PuTTY/version.h index a594e85..01c40b2 100644 --- a/0.76_My_PuTTY/version.h +++ b/0.76_My_PuTTY/version.h @@ -1,5 +1,5 @@ #define RELEASE 0.76 #define TEXTVER "Release 0.76" #define SSHVER "-Release-0.76" -#define BINARY_VERSION 0,76,0,12 +#define BINARY_VERSION 0,76,0,13 #define SOURCE_COMMIT "unavailable" diff --git a/0.76_My_PuTTY/windows/version_minor.txt b/0.76_My_PuTTY/windows/version_minor.txt index 48082f7..b1bd38b 100644 --- a/0.76_My_PuTTY/windows/version_minor.txt +++ b/0.76_My_PuTTY/windows/version_minor.txt @@ -1 +1 @@ -12 +13 diff --git a/0.76_My_PuTTY/windows/window.c b/0.76_My_PuTTY/windows/window.c index 3c79a9f..194c562 100644 --- a/0.76_My_PuTTY/windows/window.c +++ b/0.76_My_PuTTY/windows/window.c @@ -5765,13 +5765,15 @@ if( (GetKeyState(VK_MENU)&0x8000) && (wParam==VK_SPACE) ) { // send escape seq - char* str = "\x1b_f2l"; - backend_send(backend, str, strlen(str)); + if (backend) { + char* str = "\x1b_f2l"; + backend_send(backend, str, strlen(str)); - backend_send(backend, out, count); + backend_send(backend, out, count); - char* str2 = "\x07"; - backend_send(backend, str2, strlen(str2)); + char* str2 = "\x07"; + backend_send(backend, str2, strlen(str2)); + } // don't forget to free memory :) free(out); diff --git a/0.76b_My_PuTTY/windows/window.c b/0.76b_My_PuTTY/windows/window.c index 23c72a8..ed1079a 100644 --- a/0.76b_My_PuTTY/windows/window.c +++ b/0.76b_My_PuTTY/windows/window.c @@ -5765,13 +5765,13 @@ if( (GetKeyState(VK_MENU)&0x8000) && (wParam==VK_SPACE) ) { // send escape seq - if (backend) { + if (backend) { char* str = "\x1b_f2l"; backend_send(backend, str, strlen(str)); - backend_send(backend, out, count); + backend_send(backend, out, count); - char* str2 = "\x07"; + char* str2 = "\x07"; backend_send(backend, str2, strlen(str2)); } diff --git a/docs/pages/HowToCompile.md b/docs/pages/HowToCompile.md index 47d7c1f..b726b34 100644 --- a/docs/pages/HowToCompile.md +++ b/docs/pages/HowToCompile.md @@ -7,13 +7,13 @@ The best way to compile **KiTTY** is to use our cross-compile docker image: **For 32 bits compilation** ```bash -mkdir builds 2> /dev/null || rm -f builds/*.exe +mkdir -p builds 2> /dev/null || rm -f builds/*.exe docker run --rm -it -v $(pwd)/builds:/builds cyd01/cross-gcc "git clone https://github.com/cyd01/KiTTY.git ; cd KiTTY/0.76_My_PuTTY/windows ; make -f MAKEFILE.MINGW cross ; cd /builds ; ls -l" ``` **For 64 bits compilation** ```bash -mkdir builds 2> /dev/null || rm -f builds/*.exe +mkdir -p builds 2> /dev/null || rm -f builds/*.exe docker run --rm -it -v $(pwd)/builds:/builds cyd01/cross-gcc "git clone https://github.com/cyd01/KiTTY.git ; cd KiTTY/0.76_My_PuTTY/windows ; make -f MAKEFILE.MINGW cross64 ; cd /builds ; ls -l" ``` diff --git a/docs/pages/history.md b/docs/pages/history.md index 4a5550c..9713414 100644 --- a/docs/pages/history.md +++ b/docs/pages/history.md @@ -1,26 +1,28 @@ +Waou so much passion ! +First let's share some history. -Let's share some history. - -I've started to work on PuTTY in **2003** with the version **0.53** of the project. At that time, I did not use any source management solution (no git, svn, cvs or any other). The fact is that I was not a developer. I was an ops that need a software to connect servers through telnet (yes!). I liked PuTTY but I though features were missing. My first need was to automate the password negotiation on solaris or hp-ux servers: no Linux one ... and no GUI. The second need was to be able to define a specific icon for each terminal window ... the story has begun. That was the creation of **MOD_PERSO** patch (called **PERSOPORT** at this time). +I've started to work on PuTTY in **2003** with the version **0.53** of the project. At that time, no source management solution (no git, svn, cvs or any other). Remember I was not a developer. I was an ops that need a software to connect servers through telnet (yes!). I liked PuTTY but I though features were missing. My first need was to automate the password negotiation on solaris or hp-ux servers: no Linux one ... and no GUI. The second need was to be able to define a specific icon for each terminal window ... the story has begun. That was the creation of **MOD_PERSO** patch (called **PERSOPORT** at this time). My fork was build directly on my desktop computer (under Windows and GCC) and my work remains into a directory on my professional machine, nothing else. Each time a new PuTTY version was released I worked to merge it with my modifications. -In **2005** I've started to share my work. That was the creation of the [KiTTY web site](https://www.9bis.net/kitty) with the version **0.58**. After that version, people that found KiTTY useful began to ask for integration with other PuTTY forks (LePuTTY, PuTTYTray, TuTTY, RuTTY ...). Here began **MOD_*** patches. The KiTTY source files were now downloadable from the web site: a simple **.tar.gz** file that is always available [here](https://www.9bis.net/kitty/files/kitty_src.tar.gz). +In **2006** I've started to share my work. That was the creation of the [KiTTY web site](https://www.9bis.net/kitty) with the version **0.58**. After that version, people that found KiTTY useful began to ask for integration with other PuTTY forks (LePuTTY, PuTTYTray, TuTTY, RuTTY ...). Here began **MOD_*** patches. The KiTTY source files were now downloadable from the web site: a simple **.tar.gz** file that is always available [here](https://www.9bis.net/kitty/files/kitty_src.tar.gz). KiTTY became more and more popular and many requests were integrated. In **2010** I've started to use a version control system to be able to trace all the modifications I've made. In my company we used **subversion** and the very first versioned KiTTY version was **0.60.66.30**. -Late in **2013** the **0.63** PuTTY version was released. It was a big bang. The internal session settings structure was completely rewritten. It was a huge work to accomplish the merge with KiTTY. I've decided that I need help to maintain KiTTY in the future. Few months after, I've decided to share not only the source code, but the version control system too. That was the beginning of **svn** on my [web site](https://ken.9bis.com/public/websvn/listing.php?repname=Sandbox&) in **2015**. +Late in **2013** the **0.63** PuTTY version was released. It was a terrible big bang. The internal session settings structure was completely rewritten. It was a huge work to accomplish the merge with KiTTY. I've decided that I need help to maintain KiTTY in the future. Few months after, I've decided to share not only the source code, but the version control system too. That was the beginning of **svn** on my [web site](https://ken.9bis.com/public/websvn/listing.php?repname=Sandbox&) in **2015**. -Finally in **2018** I've switch to **git** with version **0.70**, and the [Gihub repository](https://github.com/cyd01/KiTTY) opened in october the same year. +Finally in **2018** I've switch to **git** with version **0.70**, and the [KiTTY Gihub repository](https://github.com/cyd01/KiTTY) opened in october the same year. -Version **0.71** was another revolution. Some of the MOD_* patches, I did not write (remember I've merge them), became broken by the last PuTTY release and I had to sacrifice some of them (cygterm, background image ...). I've asked for some help, and decided to switch completely to English (web site, comment, release notes ...) in early **2019**. At mid **2019** I abandoned the [old multi-language version of the web site](https://web.archive.org/web/20181231164209/http://www.9bis.net/kitty/) to the current English-only one, based on markdown files. +Version **0.71** in **2019** was another revolution. Some of the MOD_* patches, I did not write (remember I've merge them), became broken by the last PuTTY release and I had to sacrifice some of them (cygterm, background image ...). I've asked for some help, and decided to switch completely to English (web site, comment, release notes ...) in early **2019**. At mid **2019** I abandoned the old multi-language version of the web site to the current English-only one, based on markdown files. -Now, why not to make KiTTY compatible with Linux. First because in 2003 I simply did not think of it. Second, like I wrote, I'm not the author of all KiTTY patches, and I don't know if they are all compatible. And last, I am also a KiTTY user and I use KiTTY on Windows machine only (remember it is the only platform that did not have a ssh client in standard). When I am on a Linux GUI, I simply use **ssh** to jump to other machine. So I won't work on the Linux compatibility: I don't even know how to achieve it, and I really don't have time to make it. KiTTY is not my real job even if I really like to work on it. +The **0.77** in **mid 2022** was a little revolution too: PuTTY team decided to completely reorganize the source files structure. Many files were divided into several sub-directories. It was a good thing: the source code now is mush more easy to read. But, another time, the work to adapt KiTTY was huge. + +Now, why not to make KiTTY compatible with Linux. First because in 2003 I simply did not think of it. Second, like I wrote, I'm not the author of all KiTTY patches, and I don't know if they are all compatible. And last, I am also a KiTTY user and I use KiTTY on Windows machine only (remember it is the only platform that does not have a ssh client in standard). When I am on a Linux GUI, I simply use **ssh** to jump to other machine. So I won't work on the Linux compatibility: I don't even know how to achieve it, and I really don't have time to make it. KiTTY is not my real job even if I really like to work on it. Anyway I will try to add all the comments people need to understand my modifications. I agree with you @lars18th, I could add some generic informations to **kitty.h** file. -And above all, I've never refused to merge interesting patch in KiTTY ... but the fact is that along these 17 years I don't receive much help. I think people often mix open source with free software. Anyway feel free to propose such a patch. +And above all, I've never refused to merge interesting patch in KiTTY ... but the fact is that along these 13 years I don't receive much help. I think people often mix open source with free software. Anyway feel free to propose such a patch. All the best Cyd diff --git a/docs/version.txt b/docs/version.txt index e0b8537..0f226b8 100644 --- a/docs/version.txt +++ b/docs/version.txt @@ -1 +1 @@ -0.76.0.12 \ No newline at end of file +0.76.0.13 \ No newline at end of file diff --git a/rutty/script_ahk.c b/rutty/script_ahk.c new file mode 100644 index 0000000..f56d95e --- /dev/null +++ b/rutty/script_ahk.c @@ -0,0 +1,132 @@ +/* script_ahk.c - version 0.15.00 + + part of rutty - a modified version of putty + Copyright 2013-2014, Ernst Dijk +*/ + + +#define ruttyAHK_SIGNATURE 0x87654320 +#define ruttyAHK_send (ruttyAHK_SIGNATURE+0) //message send to rutty.exe +#define ruttyAHK_enable (ruttyAHK_SIGNATURE+8) //enable ahk mode, set ahk window name +#define ruttyAHK_set (ruttyAHK_SIGNATURE+7) //enable waitforprompt, set prompt +#define ruttyAHK_transmit (ruttyAHK_SIGNATURE+1) //data transmitted by rutty to host +#define ruttyAHK_received (ruttyAHK_SIGNATURE+2) //data received by rutty from host +#define ruttyAHK_prompt (ruttyAHK_SIGNATURE+3) //prompt received by rutty from host + + +#define ruttyAHK_wn_siz 128 +static int ruttyAHK = FALSE; //not enabled +static char ruttyAHK_windowname[ruttyAHK_wn_siz]; + +static int ruttyAHK_prompt_c = 0; +static char ruttyAHK_prompt_s[script_cond_size]; + +/* enable AHK mode + send empty string to disable +*/ +void script_ahk_enable(COPYDATASTRUCT *cds) +{ + if((cds->cbData <= 0) || (cds->cbData >= ruttyAHK_wn_siz)) //no windowname or to long - stop ruttyAHK + { + ruttyAHK = FALSE; + logevent(NULL, "AHK mode disabled"); + return; + } + + memcpy(ruttyAHK_windowname, (char *) cds->lpData, cds->cbData); + ruttyAHK_windowname[cds->cbData]='\0'; + ruttyAHK = TRUE; + logevent(NULL, "AHK mode enabled"); + return; + } + + + /* enable prompt message + send empty string to disable +*/ +void script_ahk_set(COPYDATASTRUCT *cds) +{ + int siz; + if(cds->cbData <= 0) //no new prompt + { + ruttyAHK_prompt_c = 0; + ruttyAHK_prompt_s[0] = '\0'; + logevent(NULL, "notify AHK on prompt disabled"); + return; + } + + siz = script_cond_size -1; + if(cds->cbData < siz) + siz = cds->cbData; + //memcpy(ruttyAHK_prompt_s, (char *) cds->lpData, siz); + //ruttyAHK_prompt_s[siz]='\0'; + script_cond_set(ruttyAHK_prompt_s, &ruttyAHK_prompt_c, (char *) cds->lpData, cds->cbData); + logevent(NULL, "notify AHK on prompt enabled"); + return; + } + + +/* send rutty data to ahk +*/ +void script_ahk_out(int id, char *dat, int siz) +{ + HWND hw; + COPYDATASTRUCT cds; + + if(!ruttyAHK) + return; + + //hw = FindWindow(NULL,ruttyAHK_windowname); + hw = FindWindowA(NULL,ruttyAHK_windowname); + if( hw == NULL ) + { + ruttyAHK = FALSE; + logevent(NULL, "AHK target window not found"); + return; + } + + cds.dwData = (DWORD) id; + cds.cbData = (DWORD) siz; + cds.lpData = (LPVOID) dat; + SendMessage(hw, WM_COPYDATA, (WPARAM)(HWND) MainHwnd, (LPARAM) (LPVOID) &cds); + return; +} + + +/* send message received from ahk +*/ +BOOL script_ahk_send(ScriptData * scriptdata, COPYDATASTRUCT *cds) + { + if(scriptdata->runs) + return FALSE; /* a script is already running */ + + if(cds->cbData<=0) + return FALSE; /* no data */ + + scriptdata->runs = TRUE; + script_menu(scriptdata); + + scriptdata->nextnextline = scriptdata->filebuffer = smalloc(cds->cbData); + memcpy(scriptdata->filebuffer, (char *) cds->lpData, cds->cbData); + scriptdata->filebuffer_end = &scriptdata->filebuffer[cds->cbData]; + + logevent(NULL, "sending AHK script to host ..."); + + script_getline(scriptdata); + script_chkline(scriptdata); + + if(scriptdata->enable && !scriptdata->except) /* start timeout if wait for prompt is enabled */ + { + scriptdata->send = FALSE; + scriptdata->latest = schedule_timer(scriptdata->timeout, script_timeout, scriptdata); + } + else + { + scriptdata->send = TRUE; + schedule_timer(scriptdata->line_delay, script_sendline, scriptdata); + } + return TRUE; + } + + + /* end of file */