1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00: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_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/http.c
proxy/socks4.c
@ -54,7 +54,7 @@ add_library(guiterminal STATIC
$<TARGET_OBJECTS:logging>)
add_library(noterminal STATIC
noterm.c ldisc.c)
stubs/noterm.c ldisc.c)
add_library(all-backends OBJECT
pinger.c)
@ -124,7 +124,7 @@ installed_program(psftp)
add_executable(psocks
${platform}/psocks.c
psocks.c
norand.c
stubs/norand.c
proxy/nocproxy.c
proxy/nosshproxy.c
ssh/portfwd.c)

View File

@ -389,9 +389,6 @@ void nullplug_sent(Plug *plug, size_t bufsize);
* they use types defined here.
*/
/*
* Exports from be_misc.c.
*/
void backend_socket_log(Seat *seat, LogContext *logctx,
PlugLogType type, SockAddr *addr, int port,
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}/be_none.c
${CMAKE_SOURCE_DIR}/logging.c
${CMAKE_SOURCE_DIR}/noprint.c
${CMAKE_SOURCE_DIR}/stubs/noprint.c
unicode.c
no-gtk.c)
add_dependencies(fuzzterm generated_licence_h)
@ -69,7 +69,7 @@ add_sources_from_current_dir(psocks no-gtk.c)
add_executable(psusan
psusan.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/ssh/scpserver.c
no-gtk.c
pty.c)
@ -78,7 +78,7 @@ target_link_libraries(psusan
installed_program(psusan)
add_library(puttygen-common OBJECT
${CMAKE_SOURCE_DIR}/notiming.c
${CMAKE_SOURCE_DIR}/stubs/notiming.c
keygen-noise.c
no-gtk.c
noise.c
@ -112,7 +112,7 @@ add_executable(uppity
${CMAKE_SOURCE_DIR}/ssh/scpserver.c
no-gtk.c
pty.c
${CMAKE_SOURCE_DIR}/nogss.c)
${CMAKE_SOURCE_DIR}/stubs/nogss.c)
target_link_libraries(uppity
eventloop sshserver keygen settings network crypto utils)
@ -131,9 +131,8 @@ if(GTK_FOUND)
add_executable(pageant
pageant.c
${CMAKE_SOURCE_DIR}/be_misc.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
askpass.c
x11.c
noise.c
@ -148,7 +147,7 @@ if(GTK_FOUND)
pterm.c
main-gtk-simple.c
${CMAKE_SOURCE_DIR}/be_none.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
pty.c)
target_link_libraries(pterm
@ -159,9 +158,9 @@ if(GTK_FOUND)
add_executable(ptermapp
pterm.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}/nogss.c
${CMAKE_SOURCE_DIR}/stubs/nogss.c
${CMAKE_SOURCE_DIR}/proxy/nosshproxy.c
pty.c)
target_link_libraries(ptermapp
@ -183,7 +182,7 @@ if(GTK_FOUND)
add_executable(puttyapp
putty.c
main-gtk-application.c
${CMAKE_SOURCE_DIR}/nocmdline.c
${CMAKE_SOURCE_DIR}/stubs/nocmdline.c
${CMAKE_SOURCE_DIR}/be_all_s.c)
target_link_libraries(puttyapp
guiterminal eventloop sshclient otherbackends settings
@ -194,8 +193,8 @@ if(GTK_FOUND)
putty.c
main-gtk-simple.c
${CMAKE_SOURCE_DIR}/be_nos_s.c
${CMAKE_SOURCE_DIR}/nogss.c
${CMAKE_SOURCE_DIR}/norand.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)
target_link_libraries(puttytel

View File

@ -1,5 +1,6 @@
add_sources_from_current_dir(utils
antispoof.c
backend_socket_log.c
base64_decode_atom.c
base64_encode_atom.c
bufchain.c
@ -23,6 +24,7 @@ add_sources_from_current_dir(utils
host_strcspn.c
host_strduptrim.c
host_strrchr.c
log_proxy_stderr.c
marshal.c
memory.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 <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);
}
}
void psb_init(ProxyStderrBuf *psb)
{
psb->size = 0;

View File

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