From 6a1b713e135a7db1f57017b5bbbb7fcba365204b Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 23 Aug 2022 18:57:58 +0100 Subject: [PATCH] Reorganise the stubs collection. I made a specific subdirectory 'stubs' to keep all the link-time stub modules in, like notiming.c. And I put _one_ run-time stub in it, namely nullplug.c. But the rest of the runtime stubs went into utils. I think it's better to keep all the stubs together, so I've moved all the null*.c in utils into stubs (with the exception of nullstrcmp.c, which means the 'null' in a different sense). Also, fiddled with the naming to be a bit more consistent, and stated in the new CMakeLists the naming policy that distinguishes no-*.c from null-*.c. --- CMakeLists.txt | 7 +++--- stubs/CMakeLists.txt | 30 +++++++++++++++++++++++ stubs/{nocmdline.c => no-cmdline.c} | 2 +- stubs/{nogss.c => no-gss.c} | 0 stubs/{noprint.c => no-print.c} | 0 stubs/{norand.c => no-rand.c} | 0 stubs/{noterm.c => no-term.c} | 0 stubs/{notiming.c => no-timing.c} | 2 +- utils/nullcipher.c => stubs/null-cipher.c | 0 utils/nullkey.c => stubs/null-key.c | 0 utils/null_lp.c => stubs/null-lp.c | 0 utils/nullmac.c => stubs/null-mac.c | 0 stubs/{nullplug.c => null-plug.c} | 0 utils/nullseat.c => stubs/null-seat.c | 0 unix/CMakeLists.txt | 22 ++++++++--------- utils/CMakeLists.txt | 5 ---- windows/CMakeLists.txt | 10 ++++---- 17 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 stubs/CMakeLists.txt rename stubs/{nocmdline.c => no-cmdline.c} (90%) rename stubs/{nogss.c => no-gss.c} (100%) rename stubs/{noprint.c => no-print.c} (100%) rename stubs/{norand.c => no-rand.c} (100%) rename stubs/{noterm.c => no-term.c} (100%) rename stubs/{notiming.c => no-timing.c} (92%) rename utils/nullcipher.c => stubs/null-cipher.c (100%) rename utils/nullkey.c => stubs/null-key.c (100%) rename utils/null_lp.c => stubs/null-lp.c (100%) rename utils/nullmac.c => stubs/null-mac.c (100%) rename stubs/{nullplug.c => null-plug.c} (100%) rename utils/nullseat.c => stubs/null-seat.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index deba83f7..b94d9b60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ add_library(utils STATIC ${GENERATED_COMMIT_C}) add_dependencies(utils cmake_commit_c) add_subdirectory(utils) +add_subdirectory(stubs) add_library(logging OBJECT logging.c) @@ -33,7 +34,7 @@ add_library(crypto STATIC add_subdirectory(crypto) add_library(network STATIC - stubs/nullplug.c errsock.c logging.c x11disp.c + errsock.c logging.c x11disp.c proxy/proxy.c proxy/http.c proxy/socks4.c @@ -55,7 +56,7 @@ add_library(guiterminal STATIC $) add_library(noterminal STATIC - stubs/noterm.c ldisc.c) + stubs/no-term.c ldisc.c) add_library(all-backends OBJECT pinger.c) @@ -140,7 +141,7 @@ installed_program(psftp) add_executable(psocks ${platform}/psocks.c psocks.c - stubs/norand.c + stubs/no-rand.c proxy/nocproxy.c proxy/nosshproxy.c ssh/portfwd.c) diff --git a/stubs/CMakeLists.txt b/stubs/CMakeLists.txt new file mode 100644 index 00000000..e6b2fc31 --- /dev/null +++ b/stubs/CMakeLists.txt @@ -0,0 +1,30 @@ +# This subdirectory is generally full of 'stubs' in the sense of +# functions and types that don't do anything interesting, and are +# substituted in some contexts for ones that do. +# +# Some of the files here, with names beginning 'no-', are substituted +# at link time, conditional on the application. For example, a program +# that doesn't use the timing subsystem but still includes a module +# that makes a passing reference to it (say, in a context that never +# turns out to be called) can link against no-timing.c in place of the +# real timing.c. +# +# Other files, with names beginning 'null-', provide non-functional +# implementations of a particular internal API, or a selection of +# non-functional methods for that API that real implementations can +# selectively use. Those are linked in to a program _alongside_ real +# implementations of the same API. +# +# So the cmake setup for this directory puts all the 'null-' files +# into the utils library (at the end of the link, where they'll be +# available everywhere), but doesn't mention the 'no-' files, because +# those will be selected manually by add_executable() commands +# elsewhere. + +add_sources_from_current_dir(utils + null-lp.c + null-cipher.c + null-key.c + null-mac.c + null-plug.c + null-seat.c) diff --git a/stubs/nocmdline.c b/stubs/no-cmdline.c similarity index 90% rename from stubs/nocmdline.c rename to stubs/no-cmdline.c index 60e2cb6b..2476354e 100644 --- a/stubs/nocmdline.c +++ b/stubs/no-cmdline.c @@ -1,5 +1,5 @@ /* - * nocmdline.c - stubs in applications which don't do the + * no-cmdline.c - stubs in applications which don't do the * standard(ish) PuTTY tools' command-line parsing */ diff --git a/stubs/nogss.c b/stubs/no-gss.c similarity index 100% rename from stubs/nogss.c rename to stubs/no-gss.c diff --git a/stubs/noprint.c b/stubs/no-print.c similarity index 100% rename from stubs/noprint.c rename to stubs/no-print.c diff --git a/stubs/norand.c b/stubs/no-rand.c similarity index 100% rename from stubs/norand.c rename to stubs/no-rand.c diff --git a/stubs/noterm.c b/stubs/no-term.c similarity index 100% rename from stubs/noterm.c rename to stubs/no-term.c diff --git a/stubs/notiming.c b/stubs/no-timing.c similarity index 92% rename from stubs/notiming.c rename to stubs/no-timing.c index 3feb5cdf..d1a0ef9f 100644 --- a/stubs/notiming.c +++ b/stubs/no-timing.c @@ -1,5 +1,5 @@ /* - * notiming.c: stub version of timing API. + * no-timing.c: stub version of timing API. * * Used in any tool which needs a subsystem linked against the * timing API but doesn't want to actually provide timing. For diff --git a/utils/nullcipher.c b/stubs/null-cipher.c similarity index 100% rename from utils/nullcipher.c rename to stubs/null-cipher.c diff --git a/utils/nullkey.c b/stubs/null-key.c similarity index 100% rename from utils/nullkey.c rename to stubs/null-key.c diff --git a/utils/null_lp.c b/stubs/null-lp.c similarity index 100% rename from utils/null_lp.c rename to stubs/null-lp.c diff --git a/utils/nullmac.c b/stubs/null-mac.c similarity index 100% rename from utils/nullmac.c rename to stubs/null-mac.c diff --git a/stubs/nullplug.c b/stubs/null-plug.c similarity index 100% rename from stubs/nullplug.c rename to stubs/null-plug.c diff --git a/utils/nullseat.c b/stubs/null-seat.c similarity index 100% rename from utils/nullseat.c rename to stubs/null-seat.c diff --git a/unix/CMakeLists.txt b/unix/CMakeLists.txt index 480c2162..d4de28df 100644 --- a/unix/CMakeLists.txt +++ b/unix/CMakeLists.txt @@ -53,7 +53,7 @@ add_sources_from_current_dir(agent add_executable(fuzzterm ${CMAKE_SOURCE_DIR}/test/fuzzterm.c ${CMAKE_SOURCE_DIR}/logging.c - ${CMAKE_SOURCE_DIR}/stubs/noprint.c + ${CMAKE_SOURCE_DIR}/stubs/no-print.c unicode.c no-gtk.c) be_list(fuzzterm FuZZterm) @@ -71,7 +71,7 @@ add_sources_from_current_dir(psocks no-gtk.c) add_executable(psusan psusan.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/ssh/scpserver.c no-gtk.c pty.c) @@ -81,7 +81,7 @@ target_link_libraries(psusan installed_program(psusan) add_library(puttygen-common OBJECT - ${CMAKE_SOURCE_DIR}/stubs/notiming.c + ${CMAKE_SOURCE_DIR}/stubs/no-timing.c keygen-noise.c no-gtk.c noise.c @@ -114,7 +114,7 @@ add_executable(uppity ${CMAKE_SOURCE_DIR}/ssh/scpserver.c no-gtk.c pty.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c) + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c) be_list(uppity Uppity) target_link_libraries(uppity eventloop sshserver keygen settings network crypto utils) @@ -135,7 +135,7 @@ if(GTK_FOUND) add_executable(pterm pterm.c main-gtk-simple.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/stubs/no-ca-config.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c pty.c) @@ -149,8 +149,8 @@ if(GTK_FOUND) add_executable(ptermapp pterm.c main-gtk-application.c - ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-cmdline.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/stubs/no-ca-config.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c pty.c) @@ -176,7 +176,7 @@ if(GTK_FOUND) add_executable(puttyapp putty.c main-gtk-application.c - ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c) + ${CMAKE_SOURCE_DIR}/stubs/no-cmdline.c) be_list(puttyapp PuTTY SSH SERIAL OTHERBACKENDS) target_link_libraries(puttyapp guiterminal eventloop sshclient otherbackends settings @@ -187,9 +187,9 @@ if(GTK_FOUND) add_executable(puttytel putty.c main-gtk-simple.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/stubs/no-ca-config.c - ${CMAKE_SOURCE_DIR}/stubs/norand.c + ${CMAKE_SOURCE_DIR}/stubs/no-rand.c ${CMAKE_SOURCE_DIR}/proxy/nocproxy.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c) be_list(puttytel PuTTYtel SERIAL OTHERBACKENDS) @@ -210,7 +210,7 @@ else() endif() add_executable(pageant pageant.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c x11.c noise.c ${CMAKE_SOURCE_DIR}/ssh/x11fwd.c diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 19cbc737..6ef33c8d 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -41,11 +41,6 @@ add_sources_from_current_dir(utils marshal.c memory.c memxor.c - null_lp.c - nullcipher.c - nullkey.c - nullmac.c - nullseat.c nullstrcmp.c out_of_memory.c parse_blocksize.c diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index 5f829ba8..d34b4106 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -116,9 +116,9 @@ add_executable(puttytel window.c putty.c help.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/stubs/no-ca-config.c - ${CMAKE_SOURCE_DIR}/stubs/norand.c + ${CMAKE_SOURCE_DIR}/stubs/no-rand.c ${CMAKE_SOURCE_DIR}/proxy/nocproxy.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c puttytel.rc) @@ -134,7 +134,7 @@ installed_program(puttytel) add_executable(puttygen puttygen.c - ${CMAKE_SOURCE_DIR}/stubs/notiming.c + ${CMAKE_SOURCE_DIR}/stubs/no-timing.c noise.c no-jump-list.c storage.c @@ -158,9 +158,9 @@ if(HAVE_CONPTY) pterm.c help.c conpty.c - ${CMAKE_SOURCE_DIR}/stubs/nogss.c + ${CMAKE_SOURCE_DIR}/stubs/no-gss.c ${CMAKE_SOURCE_DIR}/stubs/no-ca-config.c - ${CMAKE_SOURCE_DIR}/stubs/norand.c + ${CMAKE_SOURCE_DIR}/stubs/no-rand.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c pterm.rc) be_list(pterm pterm)