1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Merge be_*.c into one ifdef-controlled module.

This commit replaces all those fiddly little linking modules
(be_all.c, be_none.c, be_ssh.c etc) with a single source file
controlled by ifdefs, and introduces a function be_list() in
setup.cmake that makes it easy to compile a version of it appropriate
to each application.

This is a net reduction in code according to 'git diff --stat', even
though I've introduced more comments. It also gets rid of another pile
of annoying little source files in the top-level directory that didn't
deserve to take up so much room in 'ls'.

More concretely, doing this has some maintenance advantages.
Centralisation means less to maintain (e.g. n_ui_backends is worked
out once in a way that makes sense everywhere), and also, 'appname'
can now be reliably set per program. Previously, some programs got the
wrong appname due to sharing the same linking module (e.g. Plink had
appname="PuTTY"), which was a latent bug that would have manifested if
I'd wanted to reuse the same string in another context.

One thing I've changed in this rework is that Windows pterm no longer
has the ConPTY backend in its backends[]: it now has an empty one. The
special be_conpty.c module shouldn't really have been there in the
first place: it was used in the very earliest uncommitted drafts of
the ConPTY work, where I was using another method of selecting that
backend, but now that Windows pterm has a dedicated
backend_vt_from_conf() that refers to conpty_backend by name, it has
no need to live in backends[] at all, just as it doesn't have to in
Unix pterm.
This commit is contained in:
Simon Tatham
2021-11-26 17:58:55 +00:00
parent 3260e429a1
commit 53f7da8ce7
19 changed files with 158 additions and 185 deletions

View File

@ -92,8 +92,8 @@ add_executable(putty
window.c
putty.c
help.c
${CMAKE_SOURCE_DIR}/be_all_s.c
putty.rc)
be_list(putty PuTTY SSH SERIAL OTHERBACKENDS)
add_dependencies(putty generated_licence_h)
target_link_libraries(putty
guiterminal guimisc eventloop sshclient otherbackends settings network crypto
@ -108,12 +108,12 @@ add_executable(puttytel
window.c
putty.c
help.c
${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/stubs/norand.c
${CMAKE_SOURCE_DIR}/proxy/nocproxy.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
puttytel.rc)
be_list(puttytel PuTTYtel SERIAL OTHERBACKENDS)
add_dependencies(puttytel generated_licence_h)
target_link_libraries(puttytel
guiterminal guimisc eventloop otherbackends settings network utils
@ -149,11 +149,11 @@ if(HAVE_CONPTY)
pterm.c
help.c
conpty.c
be_conpty.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/stubs/norand.c
${CMAKE_SOURCE_DIR}/proxy/stubs/nosshproxy.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
pterm.rc)
be_list(pterm pterm)
add_dependencies(pterm generated_licence_h)
target_link_libraries(pterm
guiterminal guimisc eventloop settings network utils

View File

@ -1,13 +0,0 @@
#include <stdio.h>
#include "putty.h"
const char *const appname = "pterm";
const int be_default_protocol = -1;
const struct BackendVtable *const backends[] = {
&conpty_backend,
NULL
};
const size_t n_ui_backends = 1;