1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 06:38:37 -05:00

Move some more files into subdirectories.

While I'm in the mood for cleaning up the top-level directory here:
all the 'nostuff.c' files have moved into a new 'stubs' directory, and
I broke up be_misc.c into smaller modules that can live in 'utils'.
This commit is contained in:
Simon Tatham 2021-11-23 18:52:15 +00:00
parent 67b11add59
commit d13547d504
14 changed files with 84 additions and 85 deletions

View File

@ -33,7 +33,7 @@ add_library(crypto STATIC
add_subdirectory(crypto) add_subdirectory(crypto)
add_library(network STATIC add_library(network STATIC
be_misc.c nullplug.c errsock.c logging.c x11disp.c stubs/nullplug.c errsock.c logging.c x11disp.c
proxy/proxy.c proxy/proxy.c
proxy/http.c proxy/http.c
proxy/socks4.c proxy/socks4.c
@ -54,7 +54,7 @@ add_library(guiterminal STATIC
$<TARGET_OBJECTS:logging>) $<TARGET_OBJECTS:logging>)
add_library(noterminal STATIC add_library(noterminal STATIC
noterm.c ldisc.c) stubs/noterm.c ldisc.c)
add_library(all-backends OBJECT add_library(all-backends OBJECT
pinger.c) pinger.c)
@ -124,7 +124,7 @@ installed_program(psftp)
add_executable(psocks add_executable(psocks
${platform}/psocks.c ${platform}/psocks.c
psocks.c psocks.c
norand.c stubs/norand.c
proxy/nocproxy.c proxy/nocproxy.c
proxy/nosshproxy.c proxy/nosshproxy.c
ssh/portfwd.c) ssh/portfwd.c)

View File

@ -389,9 +389,6 @@ void nullplug_sent(Plug *plug, size_t bufsize);
* they use types defined here. * they use types defined here.
*/ */
/*
* Exports from be_misc.c.
*/
void backend_socket_log(Seat *seat, LogContext *logctx, void backend_socket_log(Seat *seat, LogContext *logctx,
PlugLogType type, SockAddr *addr, int port, PlugLogType type, SockAddr *addr, int port,
const char *error_msg, int error_code, Conf *conf, const char *error_msg, int error_code, Conf *conf,

View File

@ -51,7 +51,7 @@ add_executable(fuzzterm
${CMAKE_SOURCE_DIR}/fuzzterm.c ${CMAKE_SOURCE_DIR}/fuzzterm.c
${CMAKE_SOURCE_DIR}/be_none.c ${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/logging.c ${CMAKE_SOURCE_DIR}/logging.c
${CMAKE_SOURCE_DIR}/noprint.c ${CMAKE_SOURCE_DIR}/stubs/noprint.c
unicode.c unicode.c
no-gtk.c) no-gtk.c)
add_dependencies(fuzzterm generated_licence_h) add_dependencies(fuzzterm generated_licence_h)
@ -69,7 +69,7 @@ add_sources_from_current_dir(psocks no-gtk.c)
add_executable(psusan add_executable(psusan
psusan.c psusan.c
${CMAKE_SOURCE_DIR}/be_none.c ${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/ssh/scpserver.c ${CMAKE_SOURCE_DIR}/ssh/scpserver.c
no-gtk.c no-gtk.c
pty.c) pty.c)
@ -78,7 +78,7 @@ target_link_libraries(psusan
installed_program(psusan) installed_program(psusan)
add_library(puttygen-common OBJECT add_library(puttygen-common OBJECT
${CMAKE_SOURCE_DIR}/notiming.c ${CMAKE_SOURCE_DIR}/stubs/notiming.c
keygen-noise.c keygen-noise.c
no-gtk.c no-gtk.c
noise.c noise.c
@ -112,7 +112,7 @@ add_executable(uppity
${CMAKE_SOURCE_DIR}/ssh/scpserver.c ${CMAKE_SOURCE_DIR}/ssh/scpserver.c
no-gtk.c no-gtk.c
pty.c pty.c
${CMAKE_SOURCE_DIR}/nogss.c) ${CMAKE_SOURCE_DIR}/stubs/nogss.c)
target_link_libraries(uppity target_link_libraries(uppity
eventloop sshserver keygen settings network crypto utils) eventloop sshserver keygen settings network crypto utils)
@ -131,9 +131,8 @@ if(GTK_FOUND)
add_executable(pageant add_executable(pageant
pageant.c pageant.c
${CMAKE_SOURCE_DIR}/be_misc.c
${CMAKE_SOURCE_DIR}/be_none.c ${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
askpass.c askpass.c
x11.c x11.c
noise.c noise.c
@ -148,7 +147,7 @@ if(GTK_FOUND)
pterm.c pterm.c
main-gtk-simple.c main-gtk-simple.c
${CMAKE_SOURCE_DIR}/be_none.c ${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
pty.c) pty.c)
target_link_libraries(pterm target_link_libraries(pterm
@ -159,9 +158,9 @@ if(GTK_FOUND)
add_executable(ptermapp add_executable(ptermapp
pterm.c pterm.c
main-gtk-application.c main-gtk-application.c
${CMAKE_SOURCE_DIR}/nocmdline.c ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c
${CMAKE_SOURCE_DIR}/be_none.c ${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
pty.c) pty.c)
target_link_libraries(ptermapp target_link_libraries(ptermapp
@ -183,7 +182,7 @@ if(GTK_FOUND)
add_executable(puttyapp add_executable(puttyapp
putty.c putty.c
main-gtk-application.c main-gtk-application.c
${CMAKE_SOURCE_DIR}/nocmdline.c ${CMAKE_SOURCE_DIR}/stubs/nocmdline.c
${CMAKE_SOURCE_DIR}/be_all_s.c) ${CMAKE_SOURCE_DIR}/be_all_s.c)
target_link_libraries(puttyapp target_link_libraries(puttyapp
guiterminal eventloop sshclient otherbackends settings guiterminal eventloop sshclient otherbackends settings
@ -194,8 +193,8 @@ if(GTK_FOUND)
putty.c putty.c
main-gtk-simple.c main-gtk-simple.c
${CMAKE_SOURCE_DIR}/be_nos_s.c ${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/norand.c ${CMAKE_SOURCE_DIR}/stubs/norand.c
${CMAKE_SOURCE_DIR}/proxy/nocproxy.c ${CMAKE_SOURCE_DIR}/proxy/nocproxy.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c) ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c)
target_link_libraries(puttytel target_link_libraries(puttytel

View File

@ -1,5 +1,6 @@
add_sources_from_current_dir(utils add_sources_from_current_dir(utils
antispoof.c antispoof.c
backend_socket_log.c
base64_decode_atom.c base64_decode_atom.c
base64_encode_atom.c base64_encode_atom.c
bufchain.c bufchain.c
@ -23,6 +24,7 @@ add_sources_from_current_dir(utils
host_strcspn.c host_strcspn.c
host_strduptrim.c host_strduptrim.c
host_strrchr.c host_strrchr.c
log_proxy_stderr.c
marshal.c marshal.c
memory.c memory.c
memxor.c memxor.c

View File

@ -0,0 +1,62 @@
#include <assert.h>
#include <string.h>
#include "putty.h"
#include "network.h"
void backend_socket_log(Seat *seat, LogContext *logctx,
PlugLogType type, SockAddr *addr, int port,
const char *error_msg, int error_code, Conf *conf,
bool session_started)
{
char addrbuf[256], *msg;
switch (type) {
case PLUGLOG_CONNECT_TRYING:
sk_getaddr(addr, addrbuf, lenof(addrbuf));
if (sk_addr_needs_port(addr)) {
msg = dupprintf("Connecting to %s port %d", addrbuf, port);
} else {
msg = dupprintf("Connecting to %s", addrbuf);
}
break;
case PLUGLOG_CONNECT_FAILED:
sk_getaddr(addr, addrbuf, lenof(addrbuf));
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
break;
case PLUGLOG_CONNECT_SUCCESS:
if (addr)
sk_getaddr(addr, addrbuf, lenof(addrbuf));
else /* fallback if address unavailable */
sprintf(addrbuf, "remote host");
msg = dupprintf("Connected to %s", addrbuf);
break;
case PLUGLOG_PROXY_MSG: {
/* Proxy-related log messages have their own identifying
* prefix already, put on by our caller. */
int len, log_to_term;
/* Suffix \r\n temporarily, so we can log to the terminal. */
msg = dupprintf("%s\r\n", error_msg);
len = strlen(msg);
assert(len >= 2);
log_to_term = conf_get_int(conf, CONF_proxy_log_to_term);
if (log_to_term == AUTO)
log_to_term = session_started ? FORCE_OFF : FORCE_ON;
if (log_to_term == FORCE_ON)
seat_stderr(seat, msg, len);
msg[len-2] = '\0'; /* remove the \r\n again */
break;
}
default:
msg = NULL; /* shouldn't happen, but placate optimiser */
break;
}
if (msg) {
logevent(logctx, msg);
sfree(msg);
}
}

View File

@ -1,70 +1,9 @@
/*
* be_misc.c: helper functions shared between main network backends.
*/
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include "putty.h" #include "putty.h"
#include "network.h" #include "network.h"
void backend_socket_log(Seat *seat, LogContext *logctx,
PlugLogType type, SockAddr *addr, int port,
const char *error_msg, int error_code, Conf *conf,
bool session_started)
{
char addrbuf[256], *msg;
switch (type) {
case PLUGLOG_CONNECT_TRYING:
sk_getaddr(addr, addrbuf, lenof(addrbuf));
if (sk_addr_needs_port(addr)) {
msg = dupprintf("Connecting to %s port %d", addrbuf, port);
} else {
msg = dupprintf("Connecting to %s", addrbuf);
}
break;
case PLUGLOG_CONNECT_FAILED:
sk_getaddr(addr, addrbuf, lenof(addrbuf));
msg = dupprintf("Failed to connect to %s: %s", addrbuf, error_msg);
break;
case PLUGLOG_CONNECT_SUCCESS:
if (addr)
sk_getaddr(addr, addrbuf, lenof(addrbuf));
else /* fallback if address unavailable */
sprintf(addrbuf, "remote host");
msg = dupprintf("Connected to %s", addrbuf);
break;
case PLUGLOG_PROXY_MSG: {
/* Proxy-related log messages have their own identifying
* prefix already, put on by our caller. */
int len, log_to_term;
/* Suffix \r\n temporarily, so we can log to the terminal. */
msg = dupprintf("%s\r\n", error_msg);
len = strlen(msg);
assert(len >= 2);
log_to_term = conf_get_int(conf, CONF_proxy_log_to_term);
if (log_to_term == AUTO)
log_to_term = session_started ? FORCE_OFF : FORCE_ON;
if (log_to_term == FORCE_ON)
seat_stderr(seat, msg, len);
msg[len-2] = '\0'; /* remove the \r\n again */
break;
}
default:
msg = NULL; /* shouldn't happen, but placate optimiser */
break;
}
if (msg) {
logevent(logctx, msg);
sfree(msg);
}
}
void psb_init(ProxyStderrBuf *psb) void psb_init(ProxyStderrBuf *psb)
{ {
psb->size = 0; psb->size = 0;

View File

@ -109,8 +109,8 @@ add_executable(puttytel
putty.c putty.c
help.c help.c
${CMAKE_SOURCE_DIR}/be_nos_s.c ${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/norand.c ${CMAKE_SOURCE_DIR}/stubs/norand.c
${CMAKE_SOURCE_DIR}/proxy/nocproxy.c ${CMAKE_SOURCE_DIR}/proxy/nocproxy.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c ${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
puttytel.rc) puttytel.rc)
@ -125,7 +125,7 @@ installed_program(puttytel)
add_executable(puttygen add_executable(puttygen
puttygen.c puttygen.c
${CMAKE_SOURCE_DIR}/notiming.c ${CMAKE_SOURCE_DIR}/stubs/notiming.c
noise.c noise.c
no-jump-list.c no-jump-list.c
storage.c storage.c
@ -150,9 +150,9 @@ if(HAVE_CONPTY)
help.c help.c
conpty.c conpty.c
be_conpty.c be_conpty.c
${CMAKE_SOURCE_DIR}/nogss.c ${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/norand.c ${CMAKE_SOURCE_DIR}/stubs/norand.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c ${CMAKE_SOURCE_DIR}/proxy/stubs/nosshproxy.c
pterm.rc) pterm.rc)
add_dependencies(pterm generated_licence_h) add_dependencies(pterm generated_licence_h)
target_link_libraries(pterm target_link_libraries(pterm