mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 09:27:59 +00:00
Make 'LogContext' a typedef visible throughout the code.
Same principle again - the more of these structures have globally visible tags (even if the structure contents are still opaque in most places), the fewer of them I can mistake for each other.
This commit is contained in:
parent
e72e8ebe59
commit
3814a5cee8
2
cmdgen.c
2
cmdgen.c
@ -116,7 +116,7 @@ void nonfatal(const char *p, ...)
|
||||
/*
|
||||
* Stubs to let everything else link sensibly.
|
||||
*/
|
||||
void log_eventlog(void *handle, const char *event)
|
||||
void log_eventlog(LogContext *logctx, const char *event)
|
||||
{
|
||||
}
|
||||
char *x_get_default(const char *key)
|
||||
|
1
defs.h
1
defs.h
@ -45,6 +45,7 @@ typedef struct Socket_vtable Socket_vtable;
|
||||
typedef struct Plug_vtable Plug_vtable;
|
||||
|
||||
typedef struct Ldisc_tag Ldisc;
|
||||
typedef struct LogContext_tag LogContext;
|
||||
|
||||
/* Note indirection: for historical reasons (it used to be closer to
|
||||
* the OS socket type), the type that most code uses for a socket is
|
||||
|
40
logging.c
40
logging.c
@ -12,7 +12,7 @@
|
||||
#include "putty.h"
|
||||
|
||||
/* log session to file stuff ... */
|
||||
struct LogContext {
|
||||
struct LogContext_tag {
|
||||
FILE *lgfp;
|
||||
enum { L_CLOSED, L_OPENING, L_OPEN, L_ERROR } state;
|
||||
bufchain queue;
|
||||
@ -31,7 +31,7 @@ static Filename *xlatlognam(Filename *s, char *hostname, int port,
|
||||
* isn't open, buffering data if it's in the process of being
|
||||
* opened asynchronously, etc.
|
||||
*/
|
||||
static void logwrite(struct LogContext *ctx, void *data, int len)
|
||||
static void logwrite(LogContext *ctx, void *data, int len)
|
||||
{
|
||||
/*
|
||||
* In state L_CLOSED, we call logfopen, which will set the state
|
||||
@ -59,7 +59,7 @@ static void logwrite(struct LogContext *ctx, void *data, int len)
|
||||
* Convenience wrapper on logwrite() which printf-formats the
|
||||
* string.
|
||||
*/
|
||||
static void logprintf(struct LogContext *ctx, const char *fmt, ...)
|
||||
static void logprintf(LogContext *ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *data;
|
||||
@ -75,16 +75,16 @@ static void logprintf(struct LogContext *ctx, const char *fmt, ...)
|
||||
/*
|
||||
* Flush any open log file.
|
||||
*/
|
||||
void logflush(void *handle) {
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
void logflush(LogContext *ctx)
|
||||
{
|
||||
if (ctx->logtype > 0)
|
||||
if (ctx->state == L_OPEN)
|
||||
fflush(ctx->lgfp);
|
||||
}
|
||||
|
||||
static void logfopen_callback(void *handle, int mode)
|
||||
static void logfopen_callback(void *vctx, int mode)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
LogContext *ctx = (LogContext *)vctx;
|
||||
char buf[256], *event;
|
||||
struct tm tm;
|
||||
const char *fmode;
|
||||
@ -160,9 +160,8 @@ static void logfopen_callback(void *handle, int mode)
|
||||
* file and asking the user whether they want to append, overwrite
|
||||
* or cancel logging.
|
||||
*/
|
||||
void logfopen(void *handle)
|
||||
void logfopen(LogContext *ctx)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
struct tm tm;
|
||||
int mode;
|
||||
|
||||
@ -199,9 +198,8 @@ void logfopen(void *handle)
|
||||
logfopen_callback(ctx, mode); /* open the file */
|
||||
}
|
||||
|
||||
void logfclose(void *handle)
|
||||
void logfclose(LogContext *ctx)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
if (ctx->lgfp) {
|
||||
fclose(ctx->lgfp);
|
||||
ctx->lgfp = NULL;
|
||||
@ -212,9 +210,8 @@ void logfclose(void *handle)
|
||||
/*
|
||||
* Log session traffic.
|
||||
*/
|
||||
void logtraffic(void *handle, unsigned char c, int logmode)
|
||||
void logtraffic(LogContext *ctx, unsigned char c, int logmode)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
if (ctx->logtype > 0) {
|
||||
if (ctx->logtype == logmode)
|
||||
logwrite(ctx, &c, 1);
|
||||
@ -230,9 +227,8 @@ void logtraffic(void *handle, unsigned char c, int logmode)
|
||||
* platforms. Platforms which don't have a meaningful stderr can
|
||||
* just avoid defining FLAG_STDERR.
|
||||
*/
|
||||
void log_eventlog(void *handle, const char *event)
|
||||
void log_eventlog(LogContext *ctx, const char *event)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE)) {
|
||||
fprintf(stderr, "%s\n", event);
|
||||
fflush(stderr);
|
||||
@ -252,13 +248,12 @@ void log_eventlog(void *handle, const char *event)
|
||||
* If n_blanks != 0, blank or omit some parts.
|
||||
* Set of blanking areas must be in increasing order.
|
||||
*/
|
||||
void log_packet(void *handle, int direction, int type,
|
||||
void log_packet(LogContext *ctx, int direction, int type,
|
||||
const char *texttype, const void *data, int len,
|
||||
int n_blanks, const struct logblank_t *blanks,
|
||||
const unsigned long *seq,
|
||||
unsigned downstream_id, const char *additional_log_text)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
char dumpdata[80], smalldata[5];
|
||||
int p = 0, b = 0, omitted = 0;
|
||||
int output_pos = 0; /* NZ if pending output in dumpdata */
|
||||
@ -372,9 +367,9 @@ void log_packet(void *handle, int direction, int type,
|
||||
logflush(ctx);
|
||||
}
|
||||
|
||||
void *log_init(void *frontend, Conf *conf)
|
||||
LogContext *log_init(void *frontend, Conf *conf)
|
||||
{
|
||||
struct LogContext *ctx = snew(struct LogContext);
|
||||
LogContext *ctx = snew(LogContext);
|
||||
ctx->lgfp = NULL;
|
||||
ctx->state = L_CLOSED;
|
||||
ctx->frontend = frontend;
|
||||
@ -385,10 +380,8 @@ void *log_init(void *frontend, Conf *conf)
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void log_free(void *handle)
|
||||
void log_free(LogContext *ctx)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
|
||||
logfclose(ctx);
|
||||
bufchain_clear(&ctx->queue);
|
||||
if (ctx->currlogfilename)
|
||||
@ -397,9 +390,8 @@ void log_free(void *handle)
|
||||
sfree(ctx);
|
||||
}
|
||||
|
||||
void log_reconfig(void *handle, Conf *conf)
|
||||
void log_reconfig(LogContext *ctx, Conf *conf)
|
||||
{
|
||||
struct LogContext *ctx = (struct LogContext *)handle;
|
||||
int reset_logging;
|
||||
|
||||
if (!filename_equal(conf_get_filename(ctx->conf, CONF_logfilename),
|
||||
|
2
pscp.c
2
pscp.c
@ -340,7 +340,7 @@ static void do_cmd(char *host, char *user, char *cmd)
|
||||
{
|
||||
const char *err;
|
||||
char *realhost;
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
|
||||
if (host == NULL || host[0] == '\0')
|
||||
bump("Empty host name");
|
||||
|
2
psftp.c
2
psftp.c
@ -2669,7 +2669,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
|
||||
{
|
||||
char *host, *realhost;
|
||||
const char *err;
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
|
||||
/* Separate host and username */
|
||||
host = userhost;
|
||||
|
24
putty.h
24
putty.h
@ -462,7 +462,7 @@ struct backend_tag {
|
||||
int (*sendok) (void *handle);
|
||||
int (*ldisc) (void *handle, int);
|
||||
void (*provide_ldisc) (void *handle, Ldisc *ldisc);
|
||||
void (*provide_logctx) (void *handle, void *logctx);
|
||||
void (*provide_logctx) (void *handle, LogContext *logctx);
|
||||
/*
|
||||
* back->unthrottle() tells the back end that the front end
|
||||
* buffer is clearing.
|
||||
@ -1110,7 +1110,7 @@ int term_data_untrusted(Terminal *, const void *data, int len);
|
||||
void term_provide_resize_fn(Terminal *term,
|
||||
void (*resize_fn)(void *, int, int),
|
||||
void *resize_ctx);
|
||||
void term_provide_logctx(Terminal *term, void *logctx);
|
||||
void term_provide_logctx(Terminal *term, LogContext *logctx);
|
||||
void term_set_focus(Terminal *term, int has_focus);
|
||||
char *term_get_ttymode(Terminal *term, const char *mode);
|
||||
int term_get_userpass_input(Terminal *term, prompts_t *p, bufchain *input);
|
||||
@ -1120,14 +1120,14 @@ int format_arrow_key(char *buf, Terminal *term, int xkey, int ctrl);
|
||||
/*
|
||||
* Exports from logging.c.
|
||||
*/
|
||||
void *log_init(void *frontend, Conf *conf);
|
||||
void log_free(void *logctx);
|
||||
void log_reconfig(void *logctx, Conf *conf);
|
||||
void logfopen(void *logctx);
|
||||
void logfclose(void *logctx);
|
||||
void logtraffic(void *logctx, unsigned char c, int logmode);
|
||||
void logflush(void *logctx);
|
||||
void log_eventlog(void *logctx, const char *string);
|
||||
LogContext *log_init(void *frontend, Conf *conf);
|
||||
void log_free(LogContext *logctx);
|
||||
void log_reconfig(LogContext *logctx, Conf *conf);
|
||||
void logfopen(LogContext *logctx);
|
||||
void logfclose(LogContext *logctx);
|
||||
void logtraffic(LogContext *logctx, unsigned char c, int logmode);
|
||||
void logflush(LogContext *logctx);
|
||||
void log_eventlog(LogContext *logctx, const char *string);
|
||||
enum { PKT_INCOMING, PKT_OUTGOING };
|
||||
enum { PKTLOG_EMIT, PKTLOG_BLANK, PKTLOG_OMIT };
|
||||
struct logblank_t {
|
||||
@ -1135,7 +1135,7 @@ struct logblank_t {
|
||||
int len;
|
||||
int type;
|
||||
};
|
||||
void log_packet(void *logctx, int direction, int type,
|
||||
void log_packet(LogContext *logctx, int direction, int type,
|
||||
const char *texttype, const void *data, int len,
|
||||
int n_blanks, const struct logblank_t *blanks,
|
||||
const unsigned long *sequence,
|
||||
@ -1353,7 +1353,7 @@ int askappend(void *frontend, Filename *filename,
|
||||
*/
|
||||
extern int console_batch_mode;
|
||||
int console_get_userpass_input(prompts_t *p);
|
||||
void console_provide_logctx(void *logctx);
|
||||
void console_provide_logctx(LogContext *logctx);
|
||||
int is_interactive(void);
|
||||
|
||||
/*
|
||||
|
2
raw.c
2
raw.c
@ -279,7 +279,7 @@ static void raw_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
||||
static void raw_provide_logctx(void *handle, void *logctx)
|
||||
static void raw_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
2
rlogin.c
2
rlogin.c
@ -371,7 +371,7 @@ static void rlogin_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
||||
static void rlogin_provide_logctx(void *handle, void *logctx)
|
||||
static void rlogin_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
4
ssh.c
4
ssh.c
@ -701,7 +701,7 @@ struct ssh_tag {
|
||||
const Plug_vtable *plugvt;
|
||||
|
||||
Ldisc *ldisc;
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
|
||||
unsigned char session_key[32];
|
||||
int v1_remote_protoflags;
|
||||
@ -11434,7 +11434,7 @@ static void ssh_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
ssh->ldisc = ldisc;
|
||||
}
|
||||
|
||||
static void ssh_provide_logctx(void *handle, void *logctx)
|
||||
static void ssh_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
Ssh ssh = (Ssh) handle;
|
||||
ssh->logctx = logctx;
|
||||
|
2
sshbpp.h
2
sshbpp.h
@ -19,7 +19,7 @@ struct BinaryPacketProtocol {
|
||||
bufchain *in_raw, *out_raw;
|
||||
PacketQueue *in_pq;
|
||||
PacketLogSettings *pls;
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
|
||||
int seen_disconnect;
|
||||
char *error;
|
||||
|
2
telnet.c
2
telnet.c
@ -1065,7 +1065,7 @@ static void telnet_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
telnet->ldisc = ldisc;
|
||||
}
|
||||
|
||||
static void telnet_provide_logctx(void *handle, void *logctx)
|
||||
static void telnet_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
@ -6687,7 +6687,7 @@ int term_data_untrusted(Terminal *term, const void *vdata, int len)
|
||||
return 0; /* assumes that term_data() always returns 0 */
|
||||
}
|
||||
|
||||
void term_provide_logctx(Terminal *term, void *logctx)
|
||||
void term_provide_logctx(Terminal *term, LogContext *logctx)
|
||||
{
|
||||
term->logctx = logctx;
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ struct terminal_tag {
|
||||
|
||||
void *frontend;
|
||||
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
|
||||
struct unicode_data *ucsdata;
|
||||
|
||||
|
@ -50,7 +50,7 @@ static int null_exitcode(void *);
|
||||
static int null_sendok(void *);
|
||||
static int null_ldisc(void *, int);
|
||||
static void null_provide_ldisc(void *, Ldisc *);
|
||||
static void null_provide_logctx(void *, void *);
|
||||
static void null_provide_logctx(void *, LogContext *);
|
||||
static void null_unthrottle(void *, int);
|
||||
static int null_cfg_info(void *);
|
||||
|
||||
@ -161,7 +161,7 @@ static void null_provide_ldisc (void *handle, Ldisc *ldisc) {
|
||||
|
||||
}
|
||||
|
||||
static void null_provide_logctx(void *handle, void *logctx) {
|
||||
static void null_provide_logctx(void *handle, LogContext *logctx) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ struct gui_data {
|
||||
Backend *back;
|
||||
void *backhandle;
|
||||
Terminal *term;
|
||||
void *logctx;
|
||||
LogContext *logctx;
|
||||
int exited;
|
||||
struct unicode_data ucsdata;
|
||||
Conf *conf;
|
||||
|
@ -405,7 +405,7 @@ void old_keyfile_warning(void)
|
||||
postmsg(&cf);
|
||||
}
|
||||
|
||||
void console_provide_logctx(void *logctx)
|
||||
void console_provide_logctx(LogContext *logctx)
|
||||
{
|
||||
console_logctx = logctx;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ int platform_default_i(const char *name, int def) { return def; }
|
||||
FontSpec *platform_default_fontspec(const char *name) { return fontspec_new(""); }
|
||||
Filename *platform_default_filename(const char *name) { return filename_from_str(""); }
|
||||
char *x_get_default(const char *key) { return NULL; }
|
||||
void log_eventlog(void *handle, const char *event) {}
|
||||
void log_eventlog(LogContext *logctx, const char *event) {}
|
||||
int from_backend(void *frontend, int is_stderr, const void *data, int datalen)
|
||||
{ assert(!"only here to satisfy notional call from backend_socket_log"); }
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#define MAX_STDIN_BACKLOG 4096
|
||||
|
||||
static void *logctx;
|
||||
static LogContext *logctx;
|
||||
|
||||
static struct termios orig_termios;
|
||||
|
||||
|
@ -1212,7 +1212,7 @@ static void pty_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
||||
static void pty_provide_logctx(void *handle, void *logctx)
|
||||
static void pty_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* Pty pty = (Pty)handle; */
|
||||
/* This is a stub. */
|
||||
|
@ -549,7 +549,7 @@ static void serial_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
||||
static void serial_provide_logctx(void *handle, void *logctx)
|
||||
static void serial_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ void pgp_fingerprints(void)
|
||||
" " PGP_PREV_MASTER_KEY_FP "\n", stdout);
|
||||
}
|
||||
|
||||
void console_provide_logctx(void *logctx)
|
||||
void console_provide_logctx(LogContext *logctx)
|
||||
{
|
||||
console_logctx = logctx;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ static void serial_provide_ldisc(void *handle, Ldisc *ldisc)
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
||||
static void serial_provide_logctx(void *handle, void *logctx)
|
||||
static void serial_provide_logctx(void *handle, LogContext *logctx)
|
||||
{
|
||||
/* This is a stub. */
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ void quit_help(HWND hwnd);
|
||||
* windlg.c. Likewise the saved-sessions list.
|
||||
*/
|
||||
GLOBAL Terminal *term;
|
||||
GLOBAL void *logctx;
|
||||
GLOBAL LogContext *logctx;
|
||||
|
||||
/*
|
||||
* Windows-specific clipboard helper function shared with windlg.c,
|
||||
|
Loading…
Reference in New Issue
Block a user